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?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
warmspringwinds
  • 1,147
  • 2
  • 14
  • 31
  • 1
    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? – Andy Mar 20 '15 at 15:09
  • @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. – warmspringwinds Mar 20 '15 at 15:11
  • 1
    You'll have to train your own classifier. – Andy Mar 20 '15 at 15:12
  • @Andy, thank you. If you know a good German corpus, you will really help me. – warmspringwinds Mar 20 '15 at 15:34
  • 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. – bendaizer Apr 14 '15 at 15:48

5 Answers5

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
Neelisha SAXENA
  • 290
  • 1
  • 8
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.

yvespeirsman
  • 3,099
  • 20
  • 21
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.

Julien Salinas
  • 1,059
  • 1
  • 10
  • 23
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.

modarwish
  • 495
  • 10
  • 22
  • 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? – Kay Jun 27 '17 at 18:01
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.

MERose
  • 4,048
  • 7
  • 53
  • 79