Python: check whether a word is spelled correctly

Nikolai picture Nikolai · Dec 21, 2010 · Viewed 36.4k times · Source

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.

Answer

user225312 picture user225312 · Dec 21, 2010

Two possible ways of doing it:

  1. Have your own file which has all the valid words. Load the file into a set and compare each word to see whether it exists in it (word in set)
  2. (The better way) Use PyEnchant, a spell checking library for Python

PyEnchant is not actively maintained now.