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}
iCMS 回答:NLTK情绪高涨:对复合成绩和其余成绩之间的正确分析是什么?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1680205.html

大家都在问