2016-03-02 73 views
3

我得到了PyEnchant与许多语言的文件:en_US, en_AU, de_DE, fr_FR。现在我打电话给字典列表,只看到一小组:'en', 'en_US', 'en_GB', 'en_CA'。 我打电话:如何将字典添加到PyEnchant?

items = enchant._broker.list_languages() 

如何加载到附魔等LANGS?新文件?所以enchant.Dict()可以拿它。

回答

6

您可以检查是否有可用的语言,从一个Python提示符下键入:

import enchant 
print enchant.list_languages() 

然后,你需要导入它,让我们假设德国是我要找的人。然后,从终端I型:

sudo apt-get install myspell-de-de 

要检查它的工作原理,从一个Python提示符下键入:

import enchant 
d = enchant.Dict('de_DE') 
d.check("Hello") # False 
d.check("Guten") # True 

对于词典的更全面的列表,请参阅:

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

+0

我需要复制到'〜/ .enchant/myspell'。这很有帮助。 – Prog1020