微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Textblob 过度概括文本并将其归类为中性

如何解决Textblob 过度概括文本并将其归类为中性

我正在使用 textblob 来确定 Twitter 文本的情绪,但有些结果没有极性和主观性(使它们成为中性情绪 - tweets cleaned and placed in pd.dataframe)

This is a chart of the overall contrasts between sentiment (showing way more neutral)

我的代码在下面

# Create a function to get the subjectivity
def getSubjectivity(text):
   return TextBlob(text).sentiment.subjectivity

# Create a function to get the polarity
def getPolarity(text):
   return  TextBlob(text).sentiment.polarity


# Create two new columns 'Subjectivity' & 'Polarity'
df['Subjectivity'] = df['Tweets'].apply(getSubjectivity)
df['Polarity'] = df['Tweets'].apply(getPolarity)

# Show the new dataframe with columns 'Subjectivity' & 'Polarity'
df

# Subjectivity < 1  but > 0 is more factual,> 1 is very opinionated (0 and +1 are min/max)
# Polarity < 0 is more negative,> 0 is more positive (-1 and +1 are the min/max)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。