abbr2words
Multilingual, context-aware abbreviation expansion for text normalization and speech.
This standalone package was extracted from the abbreviation framework and language
registries in kokorog2p. It has no runtime dependencies and uses a flat package
layout (no src/ directory).
Supported languages
- Czech (
cs) - German (
de) - English (
en) - Spanish (
es) - French (
fr) - Italian (
it) - Portuguese (
pt)
Locale forms such as de-DE, en_GB, and pt-BR are accepted and currently map
to their base-language registry.
Installation
python -m pip install abbr2words
For development:
python -m pip install -e ".[dev]"
pytest
API
from abbr2words import abbr2words
text = "Prof. Klein kommt ggf. am Fr."
print(abbr2words(text, lang="de"))
# Professor Klein kommt gegebenenfalls am Freitag
Context can be disabled:
abbr2words("Fr. Klein", lang="de", context=False)
# Freitag Klein
Use an isolated mutable registry for project-specific entries:
from abbr2words import Expander
expander = Expander("de")
expander.add("KI", "Künstliche Intelligenz", case_sensitive=True)
print(expander("KI hilft."))
Consumers that need the shared language registry can use get_shared_expander() and
reset_expanders(). Expander and get_expander() remain isolated mutable registries.
Command line
python -m abbr2words --lang de "Prof. Klein kommt ggf."
printf 'Prof. Klein kommt ggf.' | abbr2words --lang de
Scope
abbr2words expands abbreviations only. It does not convert ordinary numbers,
dates, times, currencies, or measurements. Combine it with num2words or another
normalizer when broader text normalization is required.
Versioning
The package version is derived from Git tags by setuptools-scm. Use tags in the
form v0.2.0, v0.3.0, and so on; the corresponding package version is generated
automatically during builds. A checkout without tags falls back to 0.2.0.
For a release, commit the changes, create an annotated tag, and build from that tag:
git tag -a v0.2.0 -m "Release 0.2.0"
uv build
License
Apache License 2.0. See LICENSE and NOTICE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file abbr2words-0.1.0.tar.gz.
File metadata
- Download URL: abbr2words-0.1.0.tar.gz
- Upload date:
- Size: 54.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37291540d905975c5be3f5dcacf49f882333b4db1256757286444fa2b507150e
|
|
| MD5 |
2f8d2943b3124a63103d6a8e6596def8
|
|
| BLAKE2b-256 |
b0c31ec755c9538ec54acda7402003bf579391da495a345be135ffce622142de
|
File details
Details for the file abbr2words-0.1.0-py3-none-any.whl.
File metadata
- Download URL: abbr2words-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
067d3ae8d104871c68decc601a93e0cde89516a9946ab9225d001495a67c72eb
|
|
| MD5 |
43bef0c5f146f176194c4c47ed3f30fd
|
|
| BLAKE2b-256 |
bb8f3aa925124f6e38c52a67257ec97ab6382d79dcbe94d64ad86d2e2c940384
|