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.
-
$\begingroup$ Why should it be any different from, say, English? Python can transparently process UTF8. Do you foresee any specific problem with grammar or anything? $\endgroup$– DiegoFeb 13, 2016 at 14:55
-
$\begingroup$ @Diego, as I understand, I need a dictionary of words of the Russian language with the weight of each word (something like this for English). Which library could you advise my? $\endgroup$– MrFrollFeb 13, 2016 at 19:51
-
$\begingroup$ May be you should replace the word library with the word dictionary in your question. Python library is usually referring to a bunch of functions and classes, not just a collection of words. $\endgroup$– DiegoFeb 14, 2016 at 1:25
-
$\begingroup$ @Diego, thank you for recommendation, but I think my question correctly shows that I'm interested in dictionary or library. Both for me will be ok. $\endgroup$– MrFrollFeb 15, 2016 at 16:22
-
1$\begingroup$ Possible duplicate of Sentiment Analysis model for Spanish $\endgroup$– VividDMay 10, 2017 at 15:56
2 Answers
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.
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