繁体   English   中英

用python进行情感分析

[英]Sentiment analysis with python

我正在尝试使用python进行情感分析。我经历了各种教程,并使用了nltk,textblob等库。

但是我想要的有点不同,我无法找出任何材料

假设我有一个类似的声明

apples are tasty but they are very expensive

上面的陈述可以分为两类/标签,例如口味金钱

我的目的是要针对这两个标签表达意见

我的预期结果是对品味的 积极情绪,对金钱的 消极情绪

如何做到这一点

使用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

与维达

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挑战。

参加者很多,他们的论文被发表,组织者也发表了说明性论文。

您可以在这里与他们联系:

希望这些帮助,加油。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM