Skip to main content

Downloads

German Sentiment Classification with Bert

This package provides a very simple interface to detect the sentiment of German texts. It uses the Googles Bert architecture trained on 1.834 million samples. The training data contains texts from various domains like Twitter, Facebook and movie, app and hotel reviews. You can find more information about the dataset and the training process in the paper.

Install

To get started install the package from pypi:

pip install germansentiment

Usage

from germansentiment import SentimentModel

model = SentimentModel()

texts = [
    "Mit keinem guten Ergebniss","Das ist gar nicht mal so gut",
    "Total awesome!","nicht so schlecht wie erwartet",
    "Der Test verlief positiv.","Sie fährt ein grünes Auto."]
       
result = model.predict_sentiment(texts)
print(result)

The code above will output following list:

["negative","negative","positive","positive","neutral", "neutral"]

Output class probabilities

from germansentiment import SentimentModel

model = SentimentModel()

classes, probabilities = model.predict_sentiment(["das ist super"], output_probabilities = True) 
print(classes, probabilities)
['positive'] [[['positive', 0.9761366844177246], ['negative', 0.023540444672107697], ['neutral', 0.00032294404809363186]]]

Results

If you are interested in code and data that was used to train this model please have a look at this repository and our paper. Here is a table of the F1 scores that his model achieves on following datasets. Since we trained this model on a newer version of the transformer library, the results are slightly better than reported in the paper.

Dataset F1 micro Score
holidaycheck 0.9568
scare 0.9418
filmstarts 0.9021
germeval 0.7536
PotTS 0.6780
emotions 0.9649
sb10k 0.7376
Leipzig Wikipedia Corpus 2016 0.9967
all 0.9639

Cite

For feedback and questions contact me via e-mail or Twitter @oliverguhr. Please cite us if you found this useful:

@InProceedings{guhr-EtAl:2020:LREC,
  author    = {Guhr, Oliver  and  Schumann, Anne-Kathrin  and  Bahrmann, Frank  and  Böhme, Hans Joachim},
  title     = {Training a Broad-Coverage German Sentiment Classification Model for Dialog Systems},
  booktitle      = {Proceedings of The 12th Language Resources and Evaluation Conference},
  month          = {May},
  year           = {2020},
  address        = {Marseille, France},
  publisher      = {European Language Resources Association},
  pages     = {1620--1625},
  url       = {https://www.aclweb.org/anthology/2020.lrec-1.202.pdf}
}

Release files for germansentiment 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for germansentiment 1.1.0
File Size Uploaded
germansentiment-1.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for germansentiment 1.1.0
File Interpreter ABI Platform
germansentiment-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size:10.9 kB

Release files / germansentiment-1.1.0.tar.gz

Download URL germansentiment-1.1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
649fe5d671f0510a816e9902365e8a72fabad1ff4a36a32647d0e1d8a520ce78
BLAKE2b-256 checksum
How to use checksums
451cc02b88d5acd4609ec589c15244b6d47ad98c02d67c1ed51b8093d4003def
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / germansentiment-1.1.0-py3-none-any.whl

Download URL germansentiment-1.1.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9b3651d36e5c7c014ec8920d09782ef056e8e543780da1191f850fcb1250e3a
BLAKE2b-256 checksum
How to use checksums
3a2b0147183ca514641fa5f5dde672c6d309b765d4791405de9ec59e629ad2b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page