当我使用hunspell.spell(“我的单词”)时,我得到了一个“lookuperor”

2024-03-29 14:22:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我成功导入了咒语,但在使用时得到了一个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: 

Tags: fromimportmostinputipythoncall咒语last
1条回答
网友
1楼 · 发布于 2024-03-29 14:22:06

问题是你正在直接调用spell。您应该初始化要使用的词典的拼写:

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

相关问题 更多 >