如何在python中的tweets列上应用coreNlp(Stanford NLP)?

时间:2019-06-08 08:58:23

标签: python nlp stanford-nlp sentiment-analysis pycorenlp

我的代码是:-

import pandas as pd                  # To handle data

import numpy as np

DataSet_new = pd.read_csv("C:/Users/Sanjay-Sir/Desktop/Culture Opus Work/Dataset_Zomato_latest.csv")

str(DataSet_new["tweet_stemming"])

from pycorenlp import StanfordCoreNLP

nlp = StanfordCoreNLP('http://localhost:9000')

i=0 #counter

compval1 = [ ]  #empty list to hold our computed 'compound' VADER scores


while (i<len(DataSet_new)):

    k = nlp.annotate(DataSet_new.iloc[i]['tweet_stemming'],properties={'annotators': 'sentiment'})
    compval1.append(k["sentimentValue"], k["sentiment"])

    i = i+1

所以我的数据框是DataSet_new,我的tweet列是tweet_stemming,我想在此列上使用nlp,并且我希望在Stanford分数列中获得结果,例如(情感价值和情感)

将情感值转换为numpy以便于使用

compval1 = np.array(compval1)

len(compval1)

DataSet_new['Stanford score'] = compval1

有人可以帮助我吗?

0 个答案:

没有答案