I am interested in building a text classifier using textBlob but from my research does not look like after you train the classifier to return neutral tags. Does anyone know a way to implement this ? Or is there a similar library which provides neutral classification ? Thank you.
I am using If else Statement for this : like
from textblob import TextBlob
from textblob.sentiments import NaiveBayesAnalyzer
blob = TextBlob(message, analyzer=NaiveBayesAnalyzer())
a = (blob.sentiment)
if a.__getattribute__("p_pos") > a.__getattribute__("p_neg"):
tag = str(a.__getattribute__("classification"))
sentiment = str(a.__getattribute__("p_pos"))
elif a.__getattribute__("p_pos") < a.__getattribute__("p_neg"):
tag = str(a.__getattribute__("classification"))
sentiment = str(a.__getattribute__("p_neg"))
else:
tag = "N"
sentiment = "0"
If their is neutral sentence, p_pos and p_neg will be equal!
This works for me!!! Hope it works for you