Add dictionary to pyenchant

3k views Asked by At

Using Mac OSX 10.12.3 with Python 3. I have installed pyenchant but it only works with the preinstalled dictionaries.

    import enchant 
    print(enchant.list_languages())
    ['de_DE', 'en_AU', 'en_GB', 'en_US', 'fr_FR']

I have installed Homebrew and tried to install the Swedish language dictionary from ftp://ftp.gnu.org/gnu/aspell/dict/0index.html following this answer: https://stackoverflow.com/a/35757817/4802426

    brew install aspell-sv

     Error: No available formula with the name "aspell-sv" 
     ==> Searching for a previously deleted formula...
     Error: No previously deleted formula found.
     ==> Searching for similarly named formulae...
     Error: No similarly named formulae found.
     ==> Searching taps...
     Error: No formulae found in taps.

I've also tried to install it using this answer: https://stackoverflow.com/a/11807786/4802426 But that doesn't work either. Installing with this method works fine but when listing languages as above no new languages show up. I have tried the above mentioned methods for different languages and providers, e.g. myspell-es, aspell-es etc.

How do I move forward from here? Others must have tackled the same problem.

2

There are 2 answers

4
YwH On BEST ANSWER

Not sure whether pyenchant works fine with Python3. Did you put the downloaded dictionary file in the right site-packages folder of Python3?

Official pyenchant tutorial for osx users

Update: To find python3 site-packages folder on osx: type python3 to get into python interactive shell, then import sys;sys.exec_prefix to find your python3 path. The folder path will be appending your python3 path with /lib/pythonX.Y/site-packages, where X.Y is your python3 specific version number.

0
user2887278 On

The same problem exists when using virtual environments. enchant.Broker().describe() only lists Myspell as found provider.

Myspell dictionaries can be manually loaded from the libre office dictionaries repository and installed by copying the .dic and .aff file into the enchant side-package path. E.g. ~/.virtualenvs/<venv>/lib/python3.7/site-packages/enchant/share/enchant/myspell