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?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • 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. – Gino Mempin Feb 25 '22 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 :( – Rajesh Patnaik Feb 25 '22 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. – Rajesh Patnaik Feb 25 '22 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` – Life is complex Mar 20 '23 at 15:37

0 Answers0