Skip to main content

HanTa - The Hanover Tagger

HanTa is a pure Python package for lemmatization and POS tagging of Dutch, English and German sentences. The approach is to some extent language indpendent and language models for more langauges will be added in future.

Lemmatization and POS tagging are based on the morphological analysis of a word. The morphological analysis is done by an Hidden Markov Model that tries to find the best sequence of morphemes underlying each word.

Usage

First a model has to be loaded:

from HanTa import HanoverTagger as ht

tagger_de = ht.HanoverTagger('morphmodel_ger.pgz')
tagger_nl = ht.HanoverTagger('morphmodel_dutch.pgz')
tagger_en = ht.HanoverTagger('morphmodel_en.pgz')

Now we have three methods to anaylze words and sentences:

tagger_en.tag_word('eating')

will give a list of all possible parts of speech (PoS) for the word eating together with a probability score.

tagger_en.tag_word('eating')

The function analyze gives the most likely PoS and the lemma (VBG and eat in the exmaple below).

tagger_en.analyze('unhappiest')

Using various optional parameters we can get more information like e.g. a list of morphemes:

tagger_nl.analyze('huishoudhulpje',taglevel=3)

The last call producses the following output:

('huishoudhulp', [('huis', 'N(soort,onz)'), ('houd', 'WW'), ('hulp', 'N(soort,zijd)'), ('je', 'SUF_DIM')], 'N(soort,ev,dim,onz,stan)')

The package also contains a simple trigram based PoS tagger, that uses the probabilities from the morphological analysis for unknown words (and infrequent words from he training data).

import nltk
from pprint import pprint

sent = "Die Europawahl in den Niederlanden findet immer donnerstags statt."

words = nltk.word_tokenize(sent)
lemmata = tagger_de.tag_sent(words)
pprint(lemmata)

Further reading

For more information refer to the following resources:

  • The main documentation: The Hanover Tagger (Version 1.1.0) - Lemmatization, Morphological Analysis and POS Tagging in Python. Hannover, 2023 Online Available
  • Demo.ipynb on GitHub (https://github.com/wartaal/HanTa)
  • Original publication: Christian Wartena. A probabilistic morphology model for German lemmatization. In Proceedings of the 15th Conference on Natural Language Processing (KONVENS 2019): Long Papers, pages 40–49, Erlangen, Germany, 2019. German Society for Computational Linguistics & Language Technology. Online Available

Metadata

Release files for HanTa 1.2.1

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

Source distribution (sdist)

Source distribution for HanTa 1.2.1
File Size Uploaded
hanta-1.2.1.tar.gz 14.1 MB Details

Built distribution (wheel)

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

Total release size: 28.3 MB

Release files / hanta-1.2.1.tar.gz

Download URL hanta-1.2.1.tar.gz
Size 14.1 MB
Tags Source
SHA-256 checksum
How to use checksums
9f5ad412626dc9d8369073e5d744f90151adc56efd473335ddbaa8a4d48928ee
BLAKE2b-256 checksum
How to use checksums
98f1552fa59e8d1af8a74d3f9de9dbbff62a2989df24c04dc6b81ebccb906aaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / hanta-1.2.1-py3-none-any.whl

Download URL hanta-1.2.1-py3-none-any.whl
Size 14.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
784b03155497b6cb7b0ddc9c1f853d260cc5ab8693c211d4d045e5106bdcf8c3
BLAKE2b-256 checksum
How to use checksums
256ebbfa92af08c3acec2ca9e5aa79fde278118c73e876cd8ea08c359f6549da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

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