dasmith / stanford-corenlp-python

Python wrapper for Stanford CoreNLP tools v3.4.1
GNU General Public License v2.0
610 stars 229 forks source link

How can Stanford corenlp be used for Sentiment Analysis? #32

Open adishankar710 opened 8 years ago

adishankar710 commented 8 years ago

Hi I am planning to use python wrapper for corenlp for sentiment analysis in my lectures. Can someone please point me to some right documentation? It is a bit urgent. Thanks in advance

cuzzo commented 8 years ago

Hey @adishankar710 ,

I'm wondering the same thing. Were you ever able to get it working?

Thanks!

AlexFine commented 6 years ago

Here's an example:

from pycorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP('http://localhost:9000')
sentence = nlp.annotate("I'm so happy that CoreNLP has sentiment", properties={
    'annotators': 'sentiment',
    'outputFormat': 'json',
    'timeout': 1000,
})

for s in sentence["sentences"]:
    print(s['sentimentDistribution'])
    print(s["sentiment"])