ukr_numbers
Basics
What?
Convert int numbers (3) to (Ukrainian-language) words in
a specific declination (третій/три/третьому/третьої).
The target declination is given using natural language, in other words you show the target declination instead of describing it.
FOR EXAMPLE, if you need "1→в першому вагоні", "2→в другому вагоні", "-1→в останньому вагоні", you can just enter "першому" as your target declension, and all your integers will be transformed to ordinals in the dative case.
It additionally supports -1 as code for last, the output will be останній declined in the same shape as the numeral would be.
Why?
Declension target as natural language is neat
- I find this easier than remembering the names of everything for an explicit target declension (is it ordinal or cardinal? do I write
dativeordatv? ..) - Automatic templating! I use this package to replace numbers in strings without the need to explicitly parse each one!
More features
Even without the natural language target bit, I found no packages that could convert integers to natural language while:
- handling both cardinals and ordinals
- in different (grammatical) cases
- agreeing to numbers and genders.
Examples
>>> from ukr_numbers import Numbers
>>> Numbers().convert_to_auto(231300,"другий")
WARNING:ukr_numbers.nums:Support for multi-word numbers (231300) is bad, errors are likely to happen, you're warned.
'двістітридцятьоднатисячатрьохсотий'
python3 -m ukr_numbers 8 два
вісім
python3 -m ukr_numbers 8 другої
восьмої
# `-1` is a special number denoting "last":
python3 -m ukr_numbers -1 два #! can't decline it into a number
None
python3 -m ukr_numbers -1 другої
останньої
python3 -m ukr_numbers 124 першою
WARNING:ukr_numbers.nums:Multi-word numbers (124) are unsupported, results may be wrong.
сто двадцять четвертою
python3 -m ukr_numbers -124 першою
WARNING:ukr_numbers.nums:Multi-word numbers (-124) are unsupported, results may be wrong.
мінус сто двадцять четвертою
python3 -m ukr_numbers -1 першою
WARNING:ukr_numbers.nums:Multi-word numbers (124) are unsupported, results may be wrong.
останньою
Errors handling
- if останній/last can't be inflected in the required way, (e.g. "перший"→"останній" is OK, "один"→??? isn't) None will be returned.
- if anything goes wrong and
graceful_failureis enabled, in the worst case scenario the number itself will be returned as string (2 →'2')
Drawbacks
Explicitly unsupported
- Nouns (десятка, десяток)
- Fractions (дві з половиною тисячі)
Known bugs
Numbers that take multiple words in Ukrainian (23 → двадцять три) now have weak support, except:
- numbers composed of multiple words in certain cases (pun intended) are only partially correct
- e.g. (currently) 2000000+двома → два мільйонами, not двома мільйонами
- Please write tickets for edge cases you find!
Similar projects
Both used in this package:
Metadata
Release files for ukr-numbers 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ukr_numbers-0.1.4.tar.gz | 11.5 kB | Without provenance | Details for ukr_numbers-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ukr_numbers-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for ukr_numbers-0.1.4-py3-none-any.whl |
Total release size: 23.6 kB
Release files / ukr_numbers-0.1.4.tar.gz
| Download URL | ukr_numbers-0.1.4.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd17263acc0cf12207c6fa57be8a6ba13b3052c0c6bc10774479bfa7bf1d7f7e
|
|
BLAKE2b-256 checksum How to use checksums |
ab8caf51adbdd73d955b2d400ed6a845e7c14f5e1ef82595d669eea0d34bbb2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.1 Linux/6.6.69-1-lts
|
Release files / ukr_numbers-0.1.4-py3-none-any.whl
| Download URL | ukr_numbers-0.1.4-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19033ea4315b1687eec881f3d1ddd8d792408e8ea4b46c160b04847153b73fe4
|
|
BLAKE2b-256 checksum How to use checksums |
c5f17434c4b31e8896a757bae1e3c3153026e4c4c071393866cf62ddb2b1ae8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.1 Linux/6.6.69-1-lts
|
Security for ukr-numbers 0.1.4
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.