我已成功导入拼写,但使用拼写时出现LookupError。
from hunspell import spell
print(spell('Heello'))
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
<ipython-input-44-d22185ace6e6> in <module>
----> 1 print(spell('Hey'))
LookupError: unknown encoding:
问题是您直接呼叫咒语。您应该使用要使用的词典初始化Hunspell:
import hunspell
hobj = hunspell.HunSpell('/usr/share/hunspell/en_US.dic', '/usr/share/hunspell/en_US.aff')
print(hobj.spell("Heellow"))
词典可在以下位置找到:https://github.com/wooorm/dictionaries