Checking Sentence Similarity
We can also check the similarities between two sentences using iNLTK. This can be done using iNLTK’s get_sentence_similarity(text1, text2, language_code) function, which takes two text inputs that are to be compared and the language code as the arguments.
Example:
we check the similarity between the sentences ‘Geeks For Geeks হল একটি দুর্দান্ত প্রযুক্তি শেখার প্ল্যাটফর্ম।’ and ‘Geeks For Geeks হল একটি দুর্দান্ত কম্পিউটার বিজ্ঞান শেখার প্ল্যাটফর্ম।’ (which are Bengali translations for ‘w3wiki is a great technology learning platform’ and ‘Geeks For Geeks is an awesome computer science learning platform.’ respectively.
Python3
from inltk.inltk import get_sentence_similarity text1 = 'Geeks For Geeks হল একটি দুর্দান্ত প্রযুক্তি শেখার প্ল্যাটফর্ম।' text2 = 'Geeks For Geeks হল একটি দুর্দান্ত কম্পিউটার বিজ্ঞান শেখার প্ল্যাটফর্ম।' get_sentence_similarity(text1, text2, 'bn' ) |
Output:
We can see that the similarity score of the two sentences is quite high, as expected.
0.8634665608406067
iNLTK: Natural Language Toolkit for Indic Languages in Python
We all are aware of the popular NLP library NLTK (Natural Language Tool Kit), which is used to perform diverse NLP tasks and operations. NLTK, however, is limited to dealing with English Language only. In this article, we will explore and discuss iNLTK, which is Natural Language Tool Kit for Indic Languages. As the name suggests, iNLTK is a Python library that is used to perform NLP operations in Indian languages.
Contact Us