Pro*_*020 4 python spell-checking pyenchant
我为PyEnchant提供了许多语言的文件:en_US, en_AU, de_DE, fr_FR
.现在我调用字典列表,只看到小集:'en', 'en_US', 'en_GB', 'en_CA'
.我打电话:
items = enchant._broker.list_languages()
Run Code Online (Sandbox Code Playgroud)
如何加载Enchant其他langs?新文件?所以enchant.Dict()
可以接受它.
您可以从Python提示符类型检查您是否有可用的语言:
import enchant
print enchant.list_languages()
Run Code Online (Sandbox Code Playgroud)
然后你需要导入它,让我们假设德语是我正在寻找的.然后,从终端I输入:
sudo apt-get install myspell-de-de
Run Code Online (Sandbox Code Playgroud)
要检查它是否有效,请从Python提示符输入:
import enchant
d = enchant.Dict('de_DE')
d.check("Hello") # False
d.check("Guten") # True
Run Code Online (Sandbox Code Playgroud)
有关更完整的词典列表,请参阅:
http://packages.ubuntu.com/precise/myspell-dictionary
http://packages.ubuntu.com/precise/aspell-dictionary
http://packages.ubuntu.com/source/precise/openoffice.org-dictionaries
http://packages.ubuntu.com/precise/ispell-dictionary