Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add dictionary to PyEnchant?

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.

like image 424
Prog1020 Avatar asked Mar 02 '16 20:03

Prog1020


People also ask

What is PyEnchant in Python?

PyEnchant is a spellchecking library for Python, based on the excellent Enchant library. PyEnchant combines all the functionality of the underlying Enchant library with the flexibility of Python and a nice “Pythonic” object-oriented interface.


1 Answers

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

like image 67
user 12321 Avatar answered Oct 06 '22 14:10

user 12321