Skip to main content

wiktionary-de-parser

A Python library (3.13+) that extracts structured data from German Wiktionary XML dumps: IPA, hyphenation, inflection tables, part-of-speech tags, lemma references, rhymes, and meanings.

Features

  • Streams compressed XML dumps memory-efficiently.
  • Yields one structured entry per language and part of speech (a single Wiktionary page often holds several).
  • Optional multiprocessing mode for full-dump throughput.

Installation

pip install wiktionary-de-parser

The project uses uv for development; any standard pip/PyPI install works for consumers.

Usage

Locating the dump file

from wiktionary_de_parser import WiktionaryDump

# Either point at an existing local file.
dump = WiktionaryDump(
    dump_file_path="path/to/dewiktionary-latest-pages-articles-multistream.xml.bz2"
)

# Or download into a directory on first call.
dump = WiktionaryDump(dump_dir_path="dumps/")
dump.download_dump()

# Wikimedia requires a descriptive User-Agent. The library sends its own
# by default; pass yours if you download regularly.
dump = WiktionaryDump(
    dump_dir_path="dumps/",
    user_agent="my-app/1.0 (https://example.org; contact@example.org)",
)

Parsing entries (serial)

from wiktionary_de_parser import WiktionaryParser

parser = WiktionaryParser()

for page in dump.pages():
    if page.redirect_to or not page.wikitext:
        continue
    for entry in parser.entries(page):
        parsed = parser.parse(entry)
        if parsed.page_name == "Abend":
            print(parsed)

Parsing entries (parallel)

For full-dump runs use iter_parsed. XML iteration stays on the main process while parsing is sharded over a worker pool.

for parsed in dump.iter_parsed(workers=15):
    ...  # ParsedEntry instances yielded across all workers

workers defaults to os.cpu_count() - 1. Pass workers=1 to skip multiprocessing entirely (useful with pdb).

Output schema

ParsedEntry(
    page_name="Abend",
    page_id=2742,
    entry_index=0,
    language="Deutsch",
    language_code="de",
    lemma="Abend",
    reference=None,                          # LemmaReference if the page is an inflected/variant form
    pos=[PosTag(pos="Substantiv", subtypes=())],
    inflection={
        "gender": "m",
        "nominative_singular": "Abend",
        "nominative_plural": "Abende",
        "genitive_singular": "Abends",
        "genitive_plural": "Abende",
        "dative_singular": "Abend",
        "dative_plural": "Abenden",
        "accusative_singular": "Abend",
        "accusative_plural": "Abende",
    },
    ipa=["ˈaːbn̩t", "ˈaːbm̩t"],
    hyphenation=["Abend"],
    rhymes=["aːbn̩t"],
    meanings=[Meaning(text="…", tags=["Astronomie"], raw_tags=[])],
)

All result containers are @dataclass(slots=True). The full schema lives in wiktionary_de_parser/models.py.

Inflection keys

Inflection-table parameter names are token-translated to English lowercase + underscore: "Nominativ Singular" → "nominative_singular", "Präsens_er, sie, es" → "present_3sg". Unknown tokens are kept verbatim (lowercased).

Lemma references

If the entry is an inflected form or alternative spelling, lemma holds the canonical target and reference records the type:

# "gehörte" → "gehören"
parsed.lemma == "gehören"
parsed.reference == LemmaReference(target="gehören", type=ReferenceType.INFLECTED)

# "Geografie" → "Geographie"
parsed.reference == LemmaReference(target="Geographie", type=ReferenceType.VARIANT)

Development

uv sync                 # install dependencies
uv run pytest           # run the test suite
uv run ruff format
uv run ruff check

License

MIT © Gregor Weichbrodt

Metadata

Release files for wiktionary-de-parser 0.16.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 wiktionary-de-parser 0.16.3
File Size Uploaded Provenance Actions
wiktionary_de_parser-0.16.3.tar.gz 40.8 kB Without provenance Details for wiktionary_de_parser-0.16.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wiktionary-de-parser 0.16.3
File Interpreter ABI Platform Actions
wiktionary_de_parser-0.16.3-py3-none-any.whl Python 3 none any Details for wiktionary_de_parser-0.16.3-py3-none-any.whl

Total release size: 81.4 kB

Release files / wiktionary_de_parser-0.16.3.tar.gz

Download URL wiktionary_de_parser-0.16.3.tar.gz
Size 40.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7b34a45868c0c61abb86cec769d5ebbbe2e2f2547260c7dab1d0818b66554644
BLAKE2b-256 checksum
How to use checksums
d4ffd1da8cf76407ebfbdf6c1a90f7c5c209bfa47532d9448add8328161850dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / wiktionary_de_parser-0.16.3-py3-none-any.whl

Download URL wiktionary_de_parser-0.16.3-py3-none-any.whl
Size 40.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d6b639fa36d0f533a9ff42adf0ec32e420ab9a7f58dfae6a38b7ca436ad4930
BLAKE2b-256 checksum
How to use checksums
bdd93142db85853efcc32af11372991d3f965cd1bdaba12453cd4a3adffc4599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for wiktionary-de-parser 0.16.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.16.3 This release

2 release files No provenance

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