I try sentiment analysis of tweet text by both stanford nlp python package and the live demo, but the results are different. The result of the python package is positive while the result of the live demo is negative.
- For python package, I download stanford-corenlp-4.0.0 and install py-corenlp, basically follow the instruction in this answer: Stanford nlp for python, the code is shown below:
import pycorenlp
from pycorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP("http://localhost:9000")
text="noted former cocaine user carrie fisher says donald trump was absolutely on coke makes sense"
res = nlp.annotate(text,properties={'annotators': 'sentiment','outputFormat': 'json','timeout': 1000})
for s in res["sentences"]:
print(s["sentimentValue"], s["sentiment"])
and the result is:
3 Positive
- For the live demo: