duden is a CLI-based program and python module, which can provide various information about given german word. The provided data are parsed from german dictionary duden.de.
pip3 install duden
$ duden Löffel
Löffel, der
===========
Word type: Substantiv, maskulin
Commonness: 2/5
Separation: Löf|fel
Meaning overview:
0. a. [metallenes] [Ess]gerät, an dessen unterem Stielende eine schalenartige Vertiefung sitzt und das zur Aufnahme von Suppe, Flüssigkeiten, zur Zubereitung von Speisen o. Ä. verwendet wird
b. (Medizin) Kürette
1. (Jägersprache) Ohr von Hase und Kaninchen
Synonyms:
Ohr; [Ge]hörorgan; (salopp) Horcher, Horchlappen, Lauscher; (Jägersprache) Loser, Teller
>>> import duden
>>> w = duden.get('Loeffel')
>>> w.name
'Löffel'
>>> w.word_separation
['Löf', 'fel']
>>> w.synonyms
'Ohr; [Ge]hörorgan; (salopp) Horcher, Horchlappen, Lauscher; (Jägersprache) Loser, Teller'
For more examples see usage documentation.
Dependencies and packaging are managed by Poetry.
Install the virtual environment and enter it with
$ poetry install
$ poetry shell
To execute data tests, run
$ pytest
To run python style autoformaters (isort, black), run
$ make autoformat
Apart from English, this package has partial translations to German, Spanish, and Esperanto languages.
To test duden in other languages, set the LANG
environment variable before running duden like so:
LANG=de_DE.UTF-8 duden Kragen
LANG=es_ES.UTF-8 duden Kragen
LANG=eo_EO.UTF-8 duden Kragen
The translations are located in the duden/locale/ directory as the *.po
and duden.pot
files. The duden.pot
file defines all translatable strings in series of text blocks formatted like this:
#: main.py:82
msgid "Commonness:"
msgstr ""
while the individual language files provides translations to the strings identified by msgid
like this:
#: main.py:82
msgid "Commonness:"
msgstr "Häufigkeit:"
Note that the commented lines like #: main.py:82
do not have any functional meaning, and can get out of sync.
To build and publish the package to (test) PyPI, you can use one of these shortcut commands:
$ make pypi-publish-test
$ make pypi-publish
(these also take care of building the localization files before calling poetry publish
)
Poetry configuration for PyPI and Test PyPI credentials are well covered in this SO answer.
In order for the localization data to be included in the resulting python package, the *.po
files must be compiled using the
$ make localization
command before building the package with poetry
.