Skip to content

STANZA vs pycorenlp gives different sentiment results. #37

@shubhamk8597

Description

@shubhamk8597

I am comparing the corenlp wrapper with stanza for sentiment analysis but they output different results for many cases.
Any Idea why?
The code-

from pycorenlp import StanfordCoreNLP
text = 'Ein Neujahrsvorsatz könnte sein dass die Regierung nie vergißt, wofür das Digitale ist für alle Menschen, groß und klein.und dass sie Euch mit einbezieht und nicht nur auf die Wirtschaft schielt.'
nlp = StanfordCoreNLP('http://localhost:9000')
res = nlp.annotate(text,
properties={
'annotators': 'sentiment',
'outputFormat': 'json',
'timeout': 10000,
})

for s in res["sentences"]:
print("%d: '%s': %s %s" % (
s["index"],
" ".join([t["word"] for t in s["tokens"]]),
s["sentimentValue"], s["sentiment"]))

Output -
'Ein Neujahrsvorsatz könnte sein dass die Regierung nie vergißt , wofür das Digitale ist für alle Menschen , groß und klein.und dass sie Euch mit einbezieht und nicht nur auf die Wirtschaft schielt .': 1 Negative

import stanza
text = 'Ein Neujahrsvorsatz könnte sein dass die Regierung nie vergißt, wofür das Digitale ist für alle Menschen, groß und klein.und dass sie Euch mit einbezieht und nicht nur auf die Wirtschaft schielt.'

0 is negative, 1 is neutral, 2 is positive https://stanfordnlp.github.io/stanza/sentiment.html

nlp = stanza.Pipeline(lang='de', processors='tokenize,sentiment')
doc = nlp(text)
for a, sentence in enumerate(doc.sentences):
print(sentence.sentiment)

Output -
1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions