我正在使用 enchant 模块。它有一个属性
DictWithPWL
将个人单词列表添加到预定义的现有词典中。但我收到以下错误:
def dictionary_words_finder(word_lst):
meaningful_word = []
# creating a dictionary object for checking a word is in dictionary or not and also adding
# our personal word list from words.txt
eng_dictionary = enchant.DictWithPWL("en_US", 'words.txt')
for word in word_lst:
if not eng_dictionary.check(word):
continue
else:
meaningful_word.append(word)
return meaningful_word`
但是我收到以下错误:
AttributeError: module 'enchant' has no attribute 'DictWithPWL'
如果您没有解决上述问题,请告诉我是否有其他方法可以完成此任务。
我已经使用 !pip install enchant
安装了
enchant模块。 Enchant模块已成功安装,但问题尚未解决。另外,我搜索了执行相同任务的其他方法,但找不到任何此类模块或方法。
我希望通过对上面的代码进行一些更改,上面编写的代码不应该抛出
AttributeError
。
我还浏览了这里的文档 --> https://pyenchant.github.io/pyenchant/tutorial.html
enchant.DictWithPWL
仍在他们的文档中,但无法找到我做错的地方。请帮忙。
您安装了错误的软件包。您尝试使用的包在 PyPI 中名为
PyEnchant
。尝试卸载 enchant
并安装 PyEnchant
。