【问题标题】:Add LibreOffice dictionary to Pyenchant on Windows for Anaconda在 Windows 上为 Anaconda 添加 LibreOffice 字典到 Pyenchant
【发布时间】:2020-12-12 16:06:40
【问题描述】:

如何在 Windows 上为 anaconda 添加从 github.com/LibreOffice/dictionariespyenchant 的字典?

在 SO 上有类似的问题,但不适用于 windows:


背景

我一直在寻找一种方法来检查给定字符串是否是给定语言的有效单词。

我已经 found 并使用 pip 成功(在 Windows 10 上)在 Anaconda Prompt 中安装了 pyenchant,因为它 apparently 可以不能使用 conda 安装 win-32win-64

  (base) C:\Users\V>pip install pyenchant
    Collecting pyenchant
      Downloading pyenchant-3.2.0-py3-none-win_amd64.whl (11.9 MB)
         |████████████████████████████████| 11.9 MB 1.7 MB/s
    Installing collected packages: pyenchant
    Successfully installed pyenchant-3.2.0

这对我有用。我现在可以打开 Spyder (Python 3.6) 然后运行

import enchant 
print(enchant.list_languages())

看看我有一些英文词典

['en_BW', 'en_AU', 'en_BZ', 'en_GB', 'en_JM', 'en_DK', 'en_HK', 'en_GH', 'en_US', 'en_ZA', 'en_ZW', 'en_SG', 'en_NZ', 'en_BS', 'en_AG', 'en_PH', 'en_IE', 'en_NA', 'en_TT', 'en_IN', 'en_NG', 'en_CA']

我想使用 LibreOffice 支持的语言。

【问题讨论】:

    标签: python windows anaconda conda pyenchant


    【解决方案1】:

    找到你的 anaconda 包(应该是enchant)。

    在里面,找到你的提供者(默认应该是hunspell)。

    对我来说,这是在

    C:\Users\V\Anaconda3\Lib\site-packages\enchant\data\mingw64\share\enchant\hunspell
    

    现在,只需将所需语言的 .aff.dic 文件添加到此 hunspell 文件夹即可。

    例如,github.com/LibreOffice/dictionaries/tree/master/hr_HR 代表克罗地亚语 (Hrvatski)。

    那么例如,

    d = enchant.Dict("hr_HR")
    print(d.check("mačak"))
    

    返回

    True
    

    正如预期的那样。 (“mačak” = 克罗地亚语中雄性猫的意思。)

    【讨论】:

      猜你喜欢
      • 2017-10-11
      • 2016-06-15
      • 1970-01-01
      • 1970-01-01
      • 2012-06-10
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 2014-02-05
      相关资源
      最近更新 更多