如何使用任何Python情感分析库(NLTK / VADER)找到文本(推文)的效价,唤醒和支配地位?



我正在使用VADER&NLTK找到了一条推特的极性,但我在寻找如何找到Valence,Arousal&单独的优势值。另外,我想知道在情绪分析中,极性和价是一样的吗?你甚至可以尝试使用任何其他情绪分析库,如TextBlob、spaCy、TensorFlow等。

我找到了这个库。在我的代码中,我使用了这个.csv文件,上面写着"VAD分数"。

并应用此代码查找电子邮件的数据集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

最新更新