我正在尝试使用 python 进行情感分析。我已经阅读了各种教程并使用了 nltk、textblob 等库。
但是我想要的有点不同,我无法找到任何材料
假设我有这样的声明
apples are tasty but they are very expensive
上述说法可以分为两个类别/标签,例如味道和金钱
我的目标是了解关于这两个标签的声明的观点
我的预期结果是对品味的积极情绪,但对金钱的消极
情绪如何实现这一目标
带有文本斑点
def calculate_sentiment_textblob(current_comment):
current_comment = str(current_comment)
comment_sentiment_calculation = TextBlob(current_comment)
comment_sentiment = ""
if comment_sentiment_calculation.sentiment.polarity < 0:
comment_sentiment = "Negative"
elif comment_sentiment_calculation.sentiment.polarity > 0:
comment_sentiment = "Positive"
else:
comment_sentiment = "Neutral"
print(current_comment)
print(comment_sentiment)
sentiment_list.append(current_comment +" "+comment_sentiment)
comments_scraped.loc[comments_scraped.reviews== current_comment,'sentiment_textblob'] = comment_sentiment
与维达
def calculate_sentiment_vader(current_comment):
current_comment = str(current_comment)
comment_sentiment_calculation = sid.polarity_scores(current_comment)
comment_sentiment = ""
if comment_sentiment_calculation['compound'] < 0:
comment_sentiment = "Negative"
elif comment_sentiment_calculation['compound'] > 0:
comment_sentiment = "Positive"
else:
comment_sentiment = "Neutral"
comments_scraped.loc[comments_scraped.reviews== current_comment,'sentiment_vader'] = comment_sentiment
我建议您研究基于方面的情感分析。它不仅仅将情感集中在实体上,还集中在实体的属性上。 SemEval 挑战赛旨在研究实体属性(例如笔记本电脑和餐馆)的此问题。
参加的人很多,论文发表了,主办方也发表了解释性论文。
您可以在这里联系他们:
希望这些有帮助,干杯。