0

I am using pyspellchecker for finding wrong words. It is picking a few words as misspelled. But it suggests the same word as the correction.

Why is it doing so? Am I missing anything?

Example:

from spellchecker import SpellChecker
spell = SpellChecker()
list = ["BERHAMPUR", "berhampur", "SAHEBPARA"]
misspelled = spell.unknown(list)
print(misspelled)
for word in misspelled:
    print(spell.correction(word))

It returns as follows:

> {'sahebpara', 'berhampur'}
> 
> sahebpara berhampur

Why is misspelled and the suggested correction for each word the same?

4
  • What do you expect the corrected spelling is for "BERHAMPUR" and "SAHEBPARA"? I am not a native English speaker but to me, those don't look like it resembles any kind of English word. It seems the .correction just returns the same word if it did not find any suitable candidates. Feb 25, 2022 at 11:40
  • 1
    Actually, these are names of places. Logically, If, wrong word == 'sahebpara', then, corrected word /= 'sahebpara' If it don't get a correct word for it, then it should return a null. As you have mentioned, it returns the same word if it did not find any suitable candidates. AS per my requirement, it should have returned null :( Feb 25, 2022 at 12:27
  • As a workaround, i am checking suggested correct word with wrong word and if they are same, i consider that as null. Feb 25, 2022 at 12:34
  • pyshellchecker uses an internal dictionary to look up words. These dictionaries are limited, so place names located in India won't be in these dictionaries. Additionally your code is checking the English dictionary. And there is not a dictionary for and Indian languages within pyshellchecker Mar 20 at 15:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.