[在使用hunspell.spell(“ my_word”)时出现“ LookupError” [关闭]

问题描述 投票:-1回答:1

我已成功导入拼写,但使用拼写时出现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: 
python nlp libraries linguistics hunspell
1个回答
1
投票

问题是您直接呼叫咒语。您应该使用要使用的词典初始化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

© www.soinside.com 2019 - 2024. All rights reserved.