简体   繁体   English

如何使用任何 Python 情感分析库(NLTK/VADER)查找文本(Tweet)的价态、唤醒度和优势度?

[英]How to find Valence, Arousal & Dominance of a Text (Tweet) using any Python Sentiment Analysis Libraries(NLTK/VADER)?

I am using VADER & NLTK to find the polarity of a tweet, but I was looking for how to find Valence, Arousal & Dominance values individually.我正在使用 VADER 和 NLTK 来查找推文的极性,但我一直在寻找如何单独查找价、唤醒和支配值。 Also, I want to know does Polarity is same as Valence in Sentiment Analysis?另外,我想知道在情绪分析中极性是否与价相同? You can even try to do that using any other Sentiment Analysis Libraries like TextBlob, spaCy, TensorFlow etc.您甚至可以尝试使用任何其他情感分析库(例如 TextBlob、spaCy、TensorFlow 等)来执行此操作。

I've found this library.我找到了这个图书馆。 And in my code I've used this .csv file with words' VAD scores.在我的代码中,我使用了这个带有单词 VAD 分数的 .csv 文件。

And applied this code for finding the email's dataset VAD scores:并应用此代码来查找电子邮件的数据集 VAD 分数:

def VAD (text, vad_scores):
    i,j=0, 0
    text_vad=np.zeros([3,])
    for word in text.split(' '):
        neg=1   # reverse polarity for this word
        if word in vad_scores.index:
            if 'no' in text.split(' ')[j-6:j] or 'not' in text.split(' ')[j-6:j] or 'n\'t' in str(text.split(' ')[j-3:j]):
                neg=-1
            
            text_vad=vad_scores.loc[word]*neg + text_vad
            i+=1
                      
        j+=1   
    return text_vad.valence/i, text_vad.arousal/i, text_vad.dominance/i 
    
corpus=np.array(email['text'])
vad_scores=pd.read_csv("vad-nrc.csv", index_col='Word')
vad_feat=[VAD(text, vad_scores) for text in  corpus ]   
email[['valence', 'arousal', 'dominance']]=vad_feat

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

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