Add dictionary to pyenchant

你说的曾经没有我的故事 提交于 2021-02-08 07:42:34

问题


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.


回答1:


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.




回答2:


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



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

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