Sentiment Analysis Using Python

#import TextBlob
from textblob import TextBlob

#Example to get the polarity and subjectivity
Feedback1="The food at Sai Hotel is awesome"
Feedback2="The food at Sai Hotel is bad"

blob1=TextBlob(Feedback1)
blob2=TextBlob(Feedback2)

print(blob1.sentiment)
print(blob2.sentiment)

Output

Sentiment(polarity=1.0, subjectivity=1.0)

Sentiment(polarity=1.0, subjectivity=1.0)


#Example to perform sentiment analysis over a text data
y=input("Type your sentence...")
obj=TextBlob(y)
result=obj.sentiment.polarity
if result<0:
    print("negative")
elif result==0:
    print("neutral")
elif result>0:
    print("positive")

Output

Type your sentence...you are good
positive


About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext