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,