2016-05-11 14 views
0

私はいくつかのスペル/文法訂正スクリプトにPyEnchantを使用しています。私は私のMac上でこの行動に気づいた:数字のためのPyEnchantの奇妙な振る舞い

>>> import enchant 
>>> d = enchant.Dict('en_us') 
>>> d.suggest('50') 
['W', 'Y', 'w', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'X', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'z'] 
>>> enchant.__version__ 
'1.6.6' 

はしかし、それは私のLinuxマシン上でより多くの予想通りに動作します(pyenchantの同じバージョン)

>>> import enchant 
>>> d = enchant.Dict('en_us') 
>>> d.suggest('50') 
['5', '0', '50s'] 

答えて

0

それは、基になるプロバイダーによるものです。 Ubuntuでは、myspellとaspellの両方にen_US辞書がインストールされています。私がプロバイダを切り替えると、私は別の結果を得ます。例えば。

import enchant 

b = enchant.Broker() 
b.set_ordering("en_US","myspell,aspell") 
print b.describe() 
d=b.request_dict("en_US") 
print d.provider 
s = '50' 
print d.suggest(s) 

b = enchant.Broker() 
b.set_ordering("en_US","aspell,myspell") 
print b.describe() 
d=b.request_dict("en_US") 
print d.provider 
s = '50' 
print d.suggest(s) 

次のような出力を得ています。

[<Enchant: Aspell Provider>, <Enchant: Ispell Provider>, <Enchant: Myspell Provider>, <Enchant: Hspell Provider>] 
<Enchant: Myspell Provider> 
['5', '0', '50s'] 
[<Enchant: Aspell Provider>, <Enchant: Ispell Provider>, <Enchant: Myspell Provider>, <Enchant: Hspell Provider>] 
<Enchant: Aspell Provider> 
['W', 'Y', 'w', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'X', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'z'] 

提案の最初のセットは、あなたがLinux上で見ているが、私はのmyspellプロバイダを使用していますものです。 2番目はMacで見ているもので、Aspell Providerを使用しています。