Kalebu Jordan

Become a Pro Python Developer

Hello Guys Python is amazing , have you ever thought how to correct spelling your user may have mistaken, We will use TextBlob to perform our Automatic Spelling correction.

TextBlob

TextBlob is a Python (2 and 3) library for processing textual data. 

Installation on Linux & Window

# In Linux 
pip3 install textblob

# In Window 
pip install textblob

Once Everything Installed now let’s start Creating our Program

Importing all necessary Library

from textblob import TextBlob

Let’s create function to performing spelling correction on infinitely number of inputs

def speak():
  	while True:
      text = input('Enter anything: ')
      corrected_text = TextBlob(text).correct() #Text correction
      print(str(corrected_text))

Let’s assemble all our code together and call the speak function

app.py

from textblob import TextBlob
def speak():
  	while True:
      text = input('Enter anything: ')
      corrected_text = TextBlob(text).correct() #Text correction
      print(str(corrected_text))
 speak() #calling the function 

Once you run your code the results will look like this

Enter anything: I loveee yoo so mech
I love you so much
Enter anything: I weke up earlly everryday
I were up early everyday
Enter anything: Jumpung form tree
Jumping form tree

I also recorded a short Video about it, just click the the video below to learn more about it

Leave a Reply

error

Enjoy this blog? Please spread the word :)