Sentiment Analysis in Python from Scratch



Hi friends,

I want to do sentiment analysis in python. I am able to do in R using ‘tm’ library. In that If I insert no of reviews as text. it will go through all words and automatically identify and give positive or negative outcome of all reviews.

But How can I do in python? I gone through some site and blogs they all make separate file for positive and negative words manually and then do sentiment analysis.

Is there any Module or library in Python so I can do sentiment analysis on text of corpus?

please let me know if any module. Or else if any other method to do sentiment analysis on number of reviews in python.

Thank you in advance


Hi @premsheth,

You can go through this article to learn about Sentiment Analysis in Python:


Hi @premsheth,

Similar to the tm library in R, we have NLTK in python. You can also make use of Textblob.

In the below article, the author has used NLTK to perform sentiment analysis.

sentiment function of textblob will give you a float value which lies in the range of [-1,1] where 1 means positive statement and -1 means a negative statement.

Check section 3.6 of this article :


@PulkitS @AishwaryaSingh

Thank you so much for your kind replies. I will go through all this blogs.