NLTK情绪高涨:对复合成绩和其余成绩之间的正确分析是什么?

问题描述

我正在使用NLTK的VADER情感分析从我的数据框中获取情感。 但是,当我要确定与给定情感对应的正确值(作为字典返回)时,我遇到了麻烦。


一方面,我从字典中获得了最高的价值,除了复合值(在数据帧上称为vader或函数中的vader_label)。

但是,另一方面,如果我使用复合得分(在称为:score和compound score的数据框中;在函数:str_comp中),我将获得不同的值。

需要了解化合物的计算方式:Tag info page

通过将词典中每个单词的化合价总和求出,并根据规则进行调整,然后归一化为-1(最极端为负)和+1(最极端为正)之间,来计算复合得分。如果您想要给定句子的情感的单维测量,这是最有用的度量。称其为“标准化加权综合得分”是准确的。

positive sentiment: compound score >= 0.05
neutral sentiment: (compound score > -0.05) and (compound score < 0.05)
negative sentiment: compound score <= -0.05

def sia_vader(data,compound=False):
    '''
    This function will return the compound label
    or maximum value in the array with the label
    '''
    scores = SIA.polarity_scores(data)
    
    if compound:
        comp_score = scores['compound']
        if comp_score >= 0.05:
            str_comp = 'pos'
        elif comp_score <= -0.05:
            str_comp = 'neg'
        else: # (compound score > -0.05) and (compound score < 0.05)
            str_comp = 'neu'
        return str_comp
    else:
        del scores['compound']

        index = np.argmax(list(scores.values()))
        vader_Maxscore = list(scores.values())[index]
        vader_label = list(scores)[index]

        return vader_label

text                            |compound_score  | vader |  score   | SIA
thats bummer got carr third day |     neg        | neu   | -0.3818  | {'compound': -0.3818,'neg': 0.342,'neu': 0.658,'pos': 0.0}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...