18 lines
582 B
Python
18 lines
582 B
Python
|
import hunspell
|
||
|
|
||
|
def hunspell_spell_checker(word_list, dic_path, aff_path):
|
||
|
spellchecker = hunspell.HunSpell(dic_path, aff_path)
|
||
|
|
||
|
for word in word_list:
|
||
|
if not spellchecker.spell(word):
|
||
|
print(f"'{word}' is misspelled.")
|
||
|
suggestions = spellchecker.suggest(word)
|
||
|
if suggestions:
|
||
|
print(f"Suggestions: {suggestions}")
|
||
|
else:
|
||
|
print("No suggestions found.")
|
||
|
|
||
|
word_list = ['somthing', 'incorect', 'speling', 'wurds']
|
||
|
|
||
|
hunspell_spell_checker(word_list, './dicts/en_US.dic', './dicts/en_US.aff')
|