我正在尝试用python.I做情感分析,我已经看过各种教程,并使用了nltk、textblob等库。
但我想要的有点不同,我想不出任何材料
假设我有这样一条语句
apples are tasty but they are very expensive
上面的陈述可以分为两类/标签,如 The 和money
我的目的是了解关于这两个标签的声明的感觉
我的预期结果是对味觉的正面情绪,但对money的负面情绪
如何实现这一点
使用textblob
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
使用vader
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
发布于 2018-07-20 03:57:57
我建议你研究一下基于方面的情感分析。它不仅关注一个实体的情感,而且关注一个实体的属性。在实体的属性上调查这个问题已经存在SemEval挑战,例如笔记本电脑和餐馆。
有许多参与者,他们的论文发表了,组织者也发表了解释性论文。
你可以在这里联系到他们:
希望这些能帮上忙,干杯。
https://stackoverflow.com/questions/51407278
复制相似问题