首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用python进行情感分析

使用python进行情感分析
EN

Stack Overflow用户
提问于 2018-07-19 00:53:17
回答 1查看 1.1K关注 0票数 1

我正在尝试用python.I做情感分析,我已经看过各种教程,并使用了nltk、textblob等库。

但我想要的有点不同,我想不出任何材料

假设我有这样一条语句

代码语言:javascript
复制
apples are tasty but they are very expensive

上面的陈述可以分为两类/标签,如 The money

我的目的是了解关于这两个标签的声明的感觉

我的预期结果是对味觉的正面情绪,但对money的负面情绪

如何实现这一点

使用textblob

代码语言:javascript
复制
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

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2018-07-20 03:57:57

我建议你研究一下基于方面的情感分析。它不仅关注一个实体的情感,而且关注一个实体的属性。在实体的属性上调查这个问题已经存在SemEval挑战,例如笔记本电脑和餐馆。

有许多参与者,他们的论文发表了,组织者也发表了解释性论文。

你可以在这里联系到他们:

希望这些能帮上忙,干杯。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51407278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档