I'm looking for a an easy way to check whether a certain string is a correctly-spelled English word. For example, 'looked' would return True while 'hurrr' would return False. I don't need spelling suggestions or any spelling-correcting features. Just a simple function that takes a string and returns a boolean value.
The best way for spell checking in python is by: SymSpell, Bk-Tree or Peter Novig's method. The fastest one is SymSpell.
Two possible ways of doing it:
PyEnchant is not actively maintained now.
I was looking for the same functionality and struggled to find an existing library that works in Windows, 64 bit. PyEnchant, although a great library, isn't currently active and doesn't work in 64 bit. Other libraries I found didn't work in Windows.
I finally found a solution that I hope others will find valuable.
The solution...
in
keyword to determine if your string is in the setfrom nltk.corpus import brown
word_list = brown.words()
word_set = set(word_list)
# Check if word is in set
"looked" in word_set # Returns True
"hurrr" in word_set # Returns False
Use a timer check and you'll see this takes virtually no time to search the set. A test on 1,000 words took 0.004 seconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With