python - 我需要 Python 拼写检查器的帮助
问题描述
from spellchecker import SpellChecker
spell = SpellChecker()
misspelled = spell.unknown(['let', 'us', 'wlak','on','the','groun'])
for word in misspelled:
print(spell.correction(word))
print(spell.candidates(word))
这是程序。我收到以下错误
ValueError: 提供的字典语言 (en) 不存在
解决方案
如果您使用
pip install pyspellchecker
您需要卸载它,因为对于 2.7,它不会自动安装语言包。
pip uninstall pyspellchecker
然后你应该使用重新安装它
git clone https://github.com/barrust/pyspellchecker.git
cd pyspellchecker
python setup.py install
如果你重新运行你的程序,它现在应该可以工作了,但我想如果你想为循环中的每个单词获取候选者,你需要稍微调整一下。
from spellchecker import SpellChecker
spell = SpellChecker()
misspelled = spell.unknown(['let', 'us', 'wlak','on','the','groun'])
for word in misspelled:
print(spell.correction(word))
print(spell.candidates(word))
推荐阅读
- java - 带执行器的 Spring CommandLineRunner
- yarnpkg - 纱线设置版本不起作用。无法从 yarn 3.0.0 更改为 yarn 2.0.0
- node.js - 如何更新模型对象以包含新字段?
- android - 颤振项目构建器不将重复项视为不同的项目
- docker - 如何在 docker debian 容器中使用 root 权限在系统初始化上运行脚本?
- javascript - 单击提交按钮时将数据库中的数据显示到现有文本框中
- node.js - 发送响应后使用流/事件发射器(表达)
- google-cloud-platform - 堆栈驱动程序监控成本
- alacritty - 如何在 alacritty 中修复字体大小?
- python - 在playsound python中,它从根目录播放音乐(如C:/final.wav),但当我将文件放入文件夹时(如C:/a/final.wav)