如何在PyEnchant中添加字典?

2024-04-29 04:03:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我得到了PyEnchant和许多语言的文件:en_US, en_AU, de_DE, fr_FR。现在我调用字典列表,只看到一个小集合:'en', 'en_US', 'en_GB', 'en_CA'。 我打电话给:

items = enchant._broker.list_languages()

如何加载到附魔其他兰格?新文件?所以enchant.Dict()可以接受。


Tags: 文件语言列表字典defrenchantca
1条回答
网友
1楼 · 发布于 2024-04-29 04:03:45

您可以通过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

相关问题 更多 >