Sentiment Analysis with the NaiveBayesAnalyzer
TextBlob library also comes with a NaiveBayesAnalyzer, Naive Bayes is a commonly used machine learning text-classification algorithm.
Sentiment Analysis with the NaiveBayesAnalyzer
from textblob import TextBlob from textblob.sentiments import NaiveBayesAnalyzer blob = TextBlob("The movie was excellent!", analyzer=NaiveBayesAnalyzer()) print(blob.sentiment) blob = TextBlob("The movie story pinch me a lot.", analyzer=NaiveBayesAnalyzer()) print(blob.sentiment) blob = TextBlob("The movie actress dressing style is completely ridiculous.", analyzer=NaiveBayesAnalyzer()) print(blob.sentiment)
Sentiment(classification='pos', p_pos=0.7318278242290406, p_neg=0.2681721757709592) Sentiment(classification='neg', p_pos=0.258107501384339, p_neg=0.7418924986156609) Sentiment(classification='neg', p_pos=0.12056891642837539, p_neg=0.8794310835716243)
2019-05-12T08:00:38+05:30
2019-05-12T08:00:38+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution