跨越不同平台的附魔词典

时间:2016-02-12 23:16:02

标签: python nltk pyenchant enchant

附魔图书馆的不同结果(附魔1.6.6)

在MAC OSX 10.11.12(El Capitan)中:

>>> import enchant
>>> d = enchant.Dict("en_US")
>>> d.suggest("prfomnc")
['performance', 'prominence', 'preform', 'perform']

在Linux Ubuntu 14.04 LTS中:

>>> import enchant
>>> d = enchant.Dict("en_US")
>>> d.suggest("prfomnc")
['princedom', 'preferment', 'preform']

为什么我会在NLTK中获得不同结果和其他替代方案以获取“建议”功能?

MAC OS

>>> enchant.list_dicts()
[('de_DE', <Enchant: Myspell Provider>), ('en_AU', <Enchant: Myspell Provider>), ('en_GB', <Enchant: Myspell Provider>), ('en_US', <Enchant: Myspell Provider>), ('fr_FR', <Enchant: Myspell Provider>)]

Ubuntu的

>>> enchant.list_dicts()
[('en', <Enchant: Aspell Provider>), ('en_CA', <Enchant: Aspell Provider>), ('en_GB', <Enchant: Aspell Provider>), ('en_US', <Enchant: Aspell Provider>), ('en_ZA', <Enchant: Myspell Provider>), ('en_AU', <Enchant: Myspell Provider>)]

在我的Ubuntu尝试过:

>>> b = enchant.Broker()
>>> b.set_ordering("en_US","myspell,aspell")
>>> b.set_ordering("*","aspell,myspell")
>>> b.request_dict("en_US").provider
<Enchant: Myspell Provider>
>>> b.request_dict("en_GB").provider
<Enchant: Aspell Provider>
>>> d.suggest("prfomnc")
['princedom', 'preferment', 'preform']

但结果仍然相同

1 个答案:

答案 0 :(得分:1)

enchant库不是拼写修正库。相反,它是一个聚合器,搜索与各种支持系统的接口。

来自the documentation:

  

附魔能够同时加载多个后端。目前,Enchant有8个后端:

Aspell/Pspell (intends to replace Ispell)
Ispell (old as sin, could be interpreted as a defacto standard)
MySpell/Hunspell (an OOo project, also used by Mozilla)
Uspell (primarily Yiddish, Hebrew, and Eastern European languages - hosted in AbiWord's CVS under the module "uspell")
Hspell (Hebrew)
Zemberek (Turkish)
Voikko (Finnish)
AppleSpell (Mac OSX)

注意最后一个?

我怀疑,在不花费任何精力确认的情况下,你得到了不同的结果,因为你的MacOS系统和你的Linux系统安装了不同的拼写软件,或者他们可能安装了相同的软件,但也许他们是不同的在enchant使用的搜索路径中排序。

相关问题