Sentiment analysis of non-English texts
Asked Answered
F

5

7

I want to analyze sentiment of texts that are written in German. I found a lot of tutorials on how to do this with English, but I found none on how to apply it to different languages.

I have an idea to use the TextBlob Python library to first translate the sentences into English and then to do sentiment analysis, but I am not sure whether or not it is the best way to solve this task.

Or are there any other possible ways to solve this task?

Fulbert answered 20/3, 2015 at 15:7 Comment(5)
You apply the same logic to your German text. You need classified German text though. Is that where you are stuck? Finding a German corpus to work with?Undercoat
@Andy, I basically want to know if there exists some library that already has a trained classifier or I will have to do everything by myself.Fulbert
You'll have to train your own classifier.Undercoat
@Andy, thank you. If you know a good German corpus, you will really help me.Fulbert
If you want a corpus for binary sentiment, you can try twitter, and make a search on german tweets with positive and negative polarity, using the associated smileys :) and :( . You'll be lacking a neutral class, but it might help to get started quickly.Grimsley
S
2

As Andy has pointed about above, the best approach would be to train your own classifier. Another, more quick and dirty approach would be to use a German sentiment lexicon such as the SentiWS, and compute the polarity of a sentence simply on the basis of the polarity values of its individual words (for example by summing them). This method isn't foolproof (it doesn't take negation into account, for example), but it would give reasonable results relatively quickly.

Sniffle answered 21/3, 2015 at 6:1 Comment(0)
R
3

Now there is a pre-trained sentiment classifier for German text. Hugging Face has released two open-source APIs as follows.

  1. oliverguhr/german-sentiment-bert
  2. bert-base-german-cased-sentiment-Germeval17
Recaption answered 24/12, 2020 at 5:22 Comment(0)
S
2

As Andy has pointed about above, the best approach would be to train your own classifier. Another, more quick and dirty approach would be to use a German sentiment lexicon such as the SentiWS, and compute the polarity of a sentence simply on the basis of the polarity values of its individual words (for example by summing them). This method isn't foolproof (it doesn't take negation into account, for example), but it would give reasonable results relatively quickly.

Sniffle answered 21/3, 2015 at 6:1 Comment(0)
H
1

A lot of progress has been made for sentiment analysis in non-English languages since you asked your question 6 years ago. Today, you have very good Hugging Face Transformer based models, fine-tuned for sentiment analysis in many languages. In my opinion, the best one for German is https://huggingface.co/oliverguhr/german-sentiment-bert

If you can't or don't want to run your own model, you can also use an API like this API I developed recently: NLP Cloud. I recently added the above German model for sentiment analysis.

Non-English NLP is still far from perfect. Most datasets are in English only but the ecosystem is gradually making progress.

Higgle answered 13/8, 2021 at 10:26 Comment(0)
F
0

Or as an alternative to classification, you could use a sentiment lexicon of German subjective terms. It would be beneficial to read this paper [1]. The advantage of using a lexicon based model is that it doesn't require any training.

Another way to do it is to try a hybrid model which involves feeding the terms in the lexicon as features for the classifier itself, along with some manually annotated training set.

Furunculosis answered 2/6, 2017 at 19:47 Comment(1)
Your link results in a 404 for me. Is "Proceedings of the 1st Workshop on Computational Approaches to Subjectivity and Sentiment Analysis" the doc you meant to recommend?Ashore
I
0

There's also a dedicated German TextBlob: https://textblob-de.readthedocs.io/en/latest/ (under active development here):

Example:

from textblob_de import TextBlobDE as TextBlob

doc = "Es gibt kein richtiges Leben im falschen."
blob = TextBlob(doc)
blob.sentiment
# Sentiment(polarity=-1.0, subjectivity=0.0)

As of February 2022, there (still) is no subjectivity score available, and certain features don't work (such as .translate()). However, .noun_phrases or .tags work very well.

Ichthyic answered 2/2, 2022 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.