VOOZH about

URL: https://www.geeksforgeeks.org/python/spelling-checker-in-python/

⇱ Spelling checker in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Spelling checker in Python

Last Updated : 7 Oct, 2020

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 library


First, you need to install the library textblob using pip in command prompt. 

pip install textblob


You can also install this library in Jupyter Notebook as: 
 

  
Program for Spelling checker - 
 

Output: 
 

original text: cmputr
corrected text: computer


 

Using pyspellchecker library


You can install this library as below:
Using pip: 

pip install pyspellchecker


In Jupyter Notebook: 
 

  
Spelling Checker program using pyspellchecker - 
 

Output: 
 

computer
{'caput', 'caputs', 'compute', 'computor', 'impute', 'computer'}
water
{'water', 'watt', 'warr', 'wart', 'war', 'wath', 'wat'}
write
{'wroe', 'arte', 'wre', 'rte', 'wrote', 'write'}


Using JamSpell

To achieve the best quality while making spelling corrections dictionary-based methods are not enough. You need to consider the word surroundings. JamSpell is a python spell checking library based on a language model. It makes different corrections for a different context.

1) Install swig3

apt-get install swig3.0 # for linux
brew install swig@3 # for mac

2) Install jamspell

pip install jamspell

3) Download a language model for your language

Output:

u'I am the best spell checker!'
(u'best', u'beat', u'belt', u'bet', u'bent')
(u'checker', u'chicken', u'checked', u'wherein', u'coherent', ...)
Comment