Sentiment retriving from text (Russian)
-
16-10-2019 - |
Question
Does anybody knows python library to retrieve sentiment from Russian text. The dictionary with sentiment parameterization will be ok to. The idea of library something like in GPOMS in article.
Solution
If you are seeking a working solution, I know of an API that supports many languages, including Russian: indico.io Text Analysis sentiment()
>>> import indicoio
>>> indicoio.config.api_key = YOUR_API_KEY
>>> indicoio.sentiment(u"Это круто, убивает! Хочу.", language='ru')
0.6978093435482927
>>> indicoio.sentiment(u"Ты кто такой? Давай досвидания", language='ru')
0.13258737684773209
Note that the language
parameter is optional
(Obviously it's not a lib, but they offer a Python client and their free tier is generous enough.)
Update: As of Q2 2018, Google and IBM sentiment analysis APIs still do not support Russian.
OTHER TIPS
Take a look at the polyglot library. It has polarity lexicons for 136 languages, including Russian.
The scale of the words’ polarity consisted of three degrees: +1 for positive words, and -1 for negatives words. Neutral words will have a score of 0.
You can use it like this:
>>> from polyglot.text import Text as T
>>> text = T("это очень плохо. А это намного лучше, даже хорошо!")
>>> text.polarity
0.33333333333333331
>>> for s in text.sentences:
... s, s.polarity
...
(Sentence("это очень плохо."), -1.0)
(Sentence("А это намного лучше, даже хорошо!"), 1.0)
>>> for w in text.words:
... print("{:<16}{:>2}".format(w, w.polarity))
...
это 0
очень 0
плохо -1
. 0
А 0
это 0
намного 0
лучше 1
, 0
даже 0
хорошо 1
! 0