简体   繁体   中英

Case insensitive dictionary search with enchant

Is there a way to do a case-insensitive search in enchant?

I am trying to achieve the following:

import enchant
d = enchant.DictWithPWL("en_US","mywords.txt")

d.check("Alexandria")
True
d.check("alexandria")
False

Both cases should return True

我在任何地方都没有找到有关将Enchant设置为不区分大小写的匹配的任何信息,所以暂时这是我的解决方案,尽管它显然会大大降低性能:

if d.check(word) or d.check(word.capitalize()):

As per you example, it should return True .

import enchant
d = enchant.DictWithPWL("en_US","/home/user/yourscript.py")

a=d.check("import")
print(a)
a=d.check("Import")
print(a)

Output:

True
True

You can try following link, you may get some other alternatives to achieve this http://pythonhosted.org/pyenchant/tutorial.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM