Sunday, 1 April 2018

Simplified Text processing Example - Python

Sentiment Analysis can be used to understand human emotions and psychology using their feedback, comments or posts from social media network or any other survey platform.

Below is a very simple example in Python where just in few lines of code we could take a string input and derive a polarity out of it. I used textblob for this.

The output will be a polarity in the range of -1 to +1

-1 being negative sentiment and + 1 is very positive sentiment .

I tested 3 cases as below

a) "Last night food was good, but it was expensive"

The above sentiment resulted in a polarity of 0.06

b) "Last night food was good"

This one resulted in 0.35

c) "I went for running, it felt awesome"

This resulted in 1





No comments:

Post a Comment