python - Pyenchant store_replacement doesn't work? -
i trying of functions in pyenchant
, when tried store_replacement
, didn't work me , have no idea why. here's code:
d = enchant.dict('en_us') d.check('alllow')
out[1]: false
d.suggest('alllow')`
out[2]: ['allow',
'all low',
'all-low',
'wallop',
'allot',
'alloy',
'willow',
'allele',
'allover']
d.store_replacement('alllow', 'alloy')` d.suggest('alllow')`
out[3]: ['allow',
'all low',
'all-low',
'wallop',
'allot',
'alloy',
'willow',
'allele',
'allover']
according docs pyenchant:
store_replacement(mis, cor)
:
store replacement spelling miss-spelled word. method makes suggestion spellchecking engine miss-spelled word in fact correctly spelled cor. such suggestion typically mean cor appears in list of suggested spellings offered later instances of mis.
as see doesn't bring forward suggestion. suggestion list same. if try same thing word doesn't exists in suggestion list same.
i don't understand i'm doing wrong. appreciate help. thanks!
my understanding store_replacement needs implemented underlying provider. guess using myspell or other provider doesn't implement it. if change provider aspell implements can see working so: (note need install aspell , it's dictionaries see working)
import enchant b = enchant.broker() b.set_ordering("en_us","aspell,myspell") print b.describe() d=b.request_dict("en_us") print d.provider s = 'alllow' d.check(s) print d.suggest(s) d.store_replacement(s, 'alloy') print d.suggest(s)
after have run few times different replacements (previously "alloy", "hallow", "sallow") , in run "aloe" outputs:
[<enchant: aspell provider>, <enchant: myspell provider>, <enchant: hspell provider>, <enchant: ispell provider>] <enchant: aspell provider> ['alloy', 'hallow', 'sallow', 'all low', 'all-low', 'allow', 'allie', 'aloe', 'allows', 'all', 'callow', 'fallow', 'mallow', 'tallow', 'wallow', 'ally', 'aglow', 'allot', 'allah', 'allay', 'alley'] ['alloy', 'hallow', 'sallow', 'aloe', 'all low', 'all-low', 'allow', 'allie', 'allows', 'all', 'callow', 'fallow', 'mallow', 'tallow', 'wallow', 'ally', 'aglow', 'allot', 'allah', 'allay', 'alley']
Comments
Post a Comment