Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case insensitive dictionary search with enchant

Tags:

python

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

like image 534
404 Avatar asked Aug 30 '16 05:08

404


2 Answers

I haven't found anywhere any information on setting Enchant for case-insensitive matching, so for the time being this is my solution, though it obviously decreases performance considerably:

if d.check(word) or d.check(word.capitalize()):
like image 86
GCannizzaro Avatar answered Oct 21 '22 04:10

GCannizzaro


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

like image 23
Spike Avatar answered Oct 21 '22 04:10

Spike