Open In App
Related Articles

Python – Spelling checker using Enchant

Improve Article
Save Article
Like Article

Enchant is a module in Python, which is used to check the spelling of a word, gives suggestions to correct words. Also, gives antonym and synonym of words. It checks whether a word exists in the dictionary or not.

Enchant can also be used to check the spelling of words. The check() method returns True if the passed word is present in the language dictionary, else it returns False. This functionality of the check() method can be used to spell check words.

The suggest() method is used to suggest the correct spelling of the incorrectly spelled word. 


# import the enchant module
import enchant
# create dictionary for the language
# in use(en_US here)
dict = enchant.Dict("en_US")
# list of words
words = ["cmputr", "watr", "study", "wrte"]
# find those words that may be misspelled
misspelled =[]
for word in words:
    if dict.check(word) == False:
print("The misspelled words are : " + str(misspelled))
# suggest the correct spelling of
# the misspelled words
for word in misspelled:
    print("Suggestion for " + word + " : " + str(dict.suggest(word)))

Output : 

The misspelled words are : ['cmputr', 'watr', 'wrte']
Suggestion for cmputr : ['computer']
Suggestion for watr : ['wart', 'watt', 'wat', 'war', 'water', 'wat r']
Suggestion for wrte : ['rte', 'write', 'wrote', 'wert', 'wite', 'w rte']


Last Updated : 23 Jun, 2021
Like Article
Save Article
Similar Reads
Related Tutorials