Grammarly Lite Using Python

Ft.TextBlob

Setting Up

We would be using the Windows command line for completing this tutorial. Make sure you have Python installed on your console, and the environment variables are in the right place. If this is your first time using python on your console,

  1. Search “Python” in the search bar of the start menu
  2. Right click on the icon and press open file location
  3. In the folder you are directed to, select IDLE and go to its properties. Again click on open file location.
  4. Copy the file path and search ‘Edit the System Variable’ on the search bar of the start menu. Click on the icon to open the settings pane.
  5. Click on Environmental Variables and then double click on ‘Path’ on the bottom menu.
  6. Click add and paste the file path. Press okay and exit the window.
  7. If you have done everything right, the python environment should be ready to use.
  8. Similarly, navigate to the scripts folder and add the path to the Environmental Variables. This will make sure pip is ready to use.

TextBlob Library

TextBlob is a Python (2 and 3) library for processing textual data. It provides a simple API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, classification, translation, and more. We will be completing this project on command line.

Code For Implementing Autocorrect

pip install TextBlob #ignore if you already have it installed
Python 
from textblob import TextBlob
a= "covfee" #assigning the incorrect word to a variable
b=TextBlob(a) #here's where the magic happens
print ("Corrected Text:"+ str(b.correct()))

If you did everything, you will have your own toned down version of Grammarly. You can also add a few lines of code to make it perform sentimental analysis for you.

Code For Sentimental Analysis

pip install TextBlob 
Python 
from textblob import TextBlob
import nltk
nltk.download('punkt')
a= "covfee" #assigning the incorrect word to a variable
b=TextBlob(a) #here's where the magic happens
print ("Corrected Text:"+ str(b.correct()))
c='''Hello from the other side. He is an idiot.
He killed her mom. Lucky for you that's what I like. He is coming for you. Only Slender Man can protect ''' #we had to go a little dark to get noticeable results for sentimental analysis 
d= TextBlob(c)
for sentence in d.sentences:
    print(sentence.sentiment.polarity)

Remember that a negative polarity score indicates a negative sentiment and a positive score indicates some positive vibes.