How to add dictionary to PyEnchant?

亡梦爱人 提交于 2019-12-01 05:23:38

问题


I got PyEnchant with files for many languages: en_US, en_AU, de_DE, fr_FR. Now I call list of dictionaries and see only small set: 'en', 'en_US', 'en_GB', 'en_CA'. I call:

items = enchant._broker.list_languages()

How to load into Enchant other langs? New files? So enchant.Dict() can take it.


回答1:


You can check that you have a language available, from a Python prompt type:

import enchant
print enchant.list_languages()

Then you need to import it, lets assume german is the one I am looking for. Then, from terminal I type:

sudo apt-get install myspell-de-de

To check it works, from a Python prompt type:

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

For a fuller list of dictionaries see:

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



来源:https://stackoverflow.com/questions/35757407/how-to-add-dictionary-to-pyenchant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!