Skip to main content

GermaLemma

December 2019, Markus Konrad markus.konrad@wzb.eu / Berlin Social Science Center

A lemmatizer for German language text

Germalemma lemmatizes Part-of-Speech-tagged German language words. To do so, it combines a large lemma dictionary (an excerpt of the TIGER corpus from the University of Stuttgart), functions from the CLiPS "Pattern" package, and an algorithm to split composita.

Installation

Easy option: Installing from PyPI via pip

You can install the package from PyPI via pip:

pip install -U germalemma

Downloading and installing from source

In order to use GermaLemma, you will need to install some additional packages (see Requirements section below) and then download the TIGER corpus from the University of Stuttgart. You will need to use the CONLL09 format, not the XML format. The corpus is free to use for non-commercial purposes (see License Agreement).

Then, you should convert the corpus into pickle format for faster loading by executing germalemma.py and passing the path to the corpus file in CONLL09 format:

python germalemma.py tiger_release_[...].conll09

This will place a lemmata.pickle file in the data directory which is then automatically loaded.

Part-of-Speech (POS) Tagging

You will need to apply Part-of-Speech (POS) tagging to your text before you can lemmatize its words. See this blog post on how to do that.

Usage

You have set up GermaLemma to use the TIGER corpus (as explained above). You have tokenized your text (e.g. with NLTK). You have POS-tagged your tokens. Now you can use GermaLemma:

from germalemma import GermaLemma

lemmatizer = GermaLemma()

# passing the word and the POS tag ("N" for noun)
lemma = lemmatizer.find_lemma('Feinstaubbelastungen', 'N')
print(lemma)
# -> lemma is "Feinstaubbelastung"

Valid POS tags

You can pass POS tags from the STTS tagset, however, only four POS tags can be processed:

  • 'N...' (nouns)
  • 'V...' (verbs)
  • 'ADJ...' (adjectives)
  • 'ADV...' (adverbs)

All other POS tags will result in a ValueError so you should wrap the call to find_lemma in a try-except block.

Accuracy

GermaLemma's accuracy was evaluated using a sample of 696 POS tagged and manually lemmatized words from a sample of paragraphs from proceedings of the European Parliament, Goethe's "Werther", Kafka's "Verwandlung" and a news article from the website of the WZB (see samples in folder "eval_texts").

Under the assumption that the POS tag is correct (only those words were selected), GermaLemma finds the correct lemma in 99.43% of the cases. For comparison, Pattern achieved 95.11% for the same sample.

Requirements

  • Python 3.6 or newer
  • required package Pyphen
  • optional package PatternLite (This package is optional but highly recommended as it boosts the lemmatizer's accuracy.)

License

Apache License 2.0. See LICENSE file.

The TIGER corpus is not part of this repository and has to be downloaded separately under separate license conditions.

Metadata

Release files for germalemma 0.1.3

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

Source distribution (sdist)

Source distribution for germalemma 0.1.3
File Size Uploaded
germalemma-0.1.3.tar.gz 2.3 MB Details

Built distribution (wheel)

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

Total release size: 4.5 MB

Release files / germalemma-0.1.3.tar.gz

Download URL germalemma-0.1.3.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
9f819acfe2e5dca980571a643b395d0d88a087149e47791c4944ec86241e43e7
BLAKE2b-256 checksum
How to use checksums
1603f7897853bcdaef0722eec5c96d1e89c0a657ae33da4f6bea382a194c4e56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9

Release files / germalemma-0.1.3-py3-none-any.whl

Download URL germalemma-0.1.3-py3-none-any.whl
Size 2.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
70201de66c797722df8b0861594a9d7e0639a5801c05f3612b4e954dab4d75ff
BLAKE2b-256 checksum
How to use checksums
c194b335fa67ec8dd6fca977769c17f657526f66e0bcb3a10f44f890ea16555a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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