简体   繁体   English

如何获取每个评论中每个主题的情绪(pos/neg/neu)? 从 LDA 获得主题后?

[英]How to get sentiment (pos/neg/neu) for each topic in each review? after getting topics from LDA?

Imagine I have a reviews from Amazon.想象一下,我有来自亚马逊的评论。 I will pass those reviews into LDA model to get 4 topics.我会将这些评论传递给 LDA model 以获得 4 个主题。

Now each review might talk about more than 1 topic.现在,每条评论可能会讨论超过 1 个主题。 It might contain 2/3/4 topic words.它可能包含 2/3/4 个主题词。 So Now is there any way where I could extract sentiments from those reviews for each topic所以现在有什么方法可以让我从每个主题的评论中提取情绪

This is how I am expecting the function to be这就是我期望 function 的样子

def assign_topics_to_sentences(topics_dict,review):

   return sentences_topic_dict

#topics_dict is a dictionary that contains keys as topic number or name and values contain list like  {'topic1':[(word1,porb)(word2,prob)........],'topic2':[[(word1,porb)(word2,prob)........],.....}

#sentence_topic_dict {'topic1':(sentiment,score),'topic2':(sentiment,score)...}

Actually my main task is to get topic wise sentiment label(positive,negative,neutral for each topic for each review. If a user in a particular review doesn't talk about certain topic then its sentiment will be neutral实际上,我的主要任务是为每个评论的每个主题获取主题明智的情感标签(正面,负面,中性)。如果特定评论中的用户不谈论某个主题,那么它的情绪将是中性的


       Topic_0          Topic_1               Topic_2       Topic_3         Reviews
0   (positive, 0.4404)  (positive, 0.9612)  (neutral, 0.0)  (neutral, 0.0)  george super friendly easy going apartment gre...
1   (positive, 0.7269)  (positive, 0.9648)  (neutral, 0.0)  (neutral, 0.0)  wonderful love love love location place george...
2   (positive, 0.3182)  (positive, 0.9459)  (neutral, 0.0)  (positive, 0.4215)  brilliant time visit apartment huge great view...
3   (neutral, 0.0)      (positive, 0.9517)  (neutral, 0.0516)(neutral, 0.0)    martin great host although apartment building ...
4   (positive, 0.6705)  (positive, 0.7845)  (neutral, 0.1531)   (positive, 0.34)    would love leaving review apartment unfortunat...
5   (neutral, 0.0)  (positive, 0.946)   (positive, 0.2755)  (neutral, 0.0)  george one colleague meet location not difficu..

I want something like this for all reviews.我想要所有评论都这样。 If we could get a function for 1 review which I mentioned above we could replicate it to entire reviews.如果我们可以得到一个 function 用于我上面提到的 1 条评论,我们可以将它复制到整个评论中。

Regardless of the topics, you can have sentiment of each of your sentences using one of the many tools for sentiment analysis, then proceed with assigning each sentence, a topic.无论主题如何,您都可以使用多种情绪分析工具之一来获得每个句子的情绪,然后继续为每个句子分配一个主题。 Finally, put these two together.最后,把这两个放在一起。

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

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