Spelling Checker in Python

Spelling checker in Python, For any type of text processing or analysis, checking the spelling of the word is one of the basic requirements.

This article discusses various ways that you can check the spellings of the words and also can correct the spelling of the respective word.

Using textblob module

First we check spelling using textblob module.

Installation

pip install textblob

Code

# using textblob

from textblob import TextBlob 
  
a = "comuter progrming is gret"
print("original text: "+str(a)) 
  
b = TextBlob(a) 

print("corrected text: "+str(b.correct()))    

#Follow @code_snail

Output:

spelling checker in python

Read more about textblob: https://pypi.org/project/textblob/

Using pyspellchecker module

Now using pyspellchecker module

Installation

pip install pyspellchecker

Code

# using pyspellchecker

from spellchecker import SpellChecker

spell = SpellChecker()

# find those words that may be misspelled
misspelled = spell.unknown(['something', 'is', 'hapenning', 'here'])

for word in misspelled:
    # Get the one `most likely` answer
    print(spell.correction(word))

    # Get a list of `likely` options
    print(spell.candidates(word))

#Follow @code_snail

Output:

spelling checker in python

Read more about pyspellchecker: https://pypi.org/project/pyspellchecker/

Also see,

Support CodeSnail

If you appreciate my work, or if it has helped you along your journey. It would mean a lot to me if you could write a message on my wall and share a cup of coffee (or tea) with me.

Buy Me A Coffee
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.

Leave a Comment