0

我有兴趣使用 textBlob 构建文本分类器,但根据我的研究,在您训练分类器以返回中性标签后看起来并不像。有谁知道实现这一点的方法?或者是否有提供中性分类的类似库?谢谢你。

4

1 回答 1

1

我为此使用 If else 语句:比如

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"

如果它们是中性句,则 p_pos 和 p_neg 将相等!

这对我有用!!!希望这对你有用

于 2016-03-14T06:51:59.103 回答