我想做一个拼写检查器,如果有任何错误,它可以纠正用户输入。 我使用symspellpy和海关数据库作为字典
from symspellpy import SymSpell
sym_spell = SymSpell()
corpus_path = 'D:\Pursuit soft\dict\words2.txt'
sym_spell.create_dictionary(corpus_path)
print(sym_spell.words)
现在,当我将其与以下代码一起使用时
from symspellpy import SymSpell, Verbosity
input_term='cmments'
suggestions = sym_spell.lookup(input_term, Verbosity.CLOSEST,
max_edit_distance=2, include_unknown=True)
for suggestion in suggestions:
print(suggestion)
结果是: “cmments”变成了“comments,1,8”…这是正确的..但我只是单词,而不是距离和频率..如何只提取单词
lookup的返回值是
SuggestItem
的列表。您可以通过以下方式获得建议的术语:相关问题 更多 >
编程相关推荐