Python library for declension of Ukrainian anthroponyms
Project description
shevchenko-python
Python library for declension of Ukrainian anthroponyms. Port of shevchenko.js.
Installation
pip install shevchenko
Usage
from shevchenko import in_nominative, in_genitive, in_dative, in_accusative, in_ablative, in_locative, in_vocative, GrammaticalGender
input_data = {
'gender': GrammaticalGender.MASCULINE,
'givenName': 'Тарас',
'patronymicName': 'Григорович',
'familyName': 'Шевченко'
}
# Nominative: Тарас Григорович Шевченко
print(in_nominative(input_data))
# Genitive: Тараса Григоровича Шевченка
print(in_genitive(input_data))
# Dative: Тарасу Григоровичу Шевченку
print(in_dative(input_data))
# Accusative: Тараса Григоровича Шевченка
print(in_accusative(input_data))
# Ablative: Тарасом Григоровичем Шевченком
print(in_ablative(input_data))
# Locative: Тарасові Григоровичу Шевченку
print(in_locative(input_data))
# Vocative: Тарасе Григоровичу Шевченку
print(in_vocative(input_data))
Using Extensions
You can extend the library to support declension of additional fields. For example, to declin military ranks and appointments using the shevchenko-ext-military extension:
from shevchenko import inflect, GrammaticalCase
from shevchenko.extension import register_extension
from shevchenko_ext_military import military_extension
# Register the military extension
register_extension(military_extension)
input_data = {
'gender': 'masculine',
'givenName': 'Тарас',
'familyName': 'Шевченко',
'militaryRank': 'Генерал-майор',
'militaryAppointment': 'Командир'
}
# Inflect including the custom fields
result = inflect(input_data, GrammaticalCase.DATIVE)
print(f"{result['militaryRank']} {result['militaryAppointment']} {result['givenName']} {result['familyName']}")
# Output: Генерал-майору Командиру Тарасу Шевченку
Features
- Declension of given names, patronymic names, and family names.
- Auto-detection of grammatical gender (if not provided, though recommended to provide).
- Support for all grammatical cases.
- Uses
regexlibrary for advanced pattern matching compatibility with JS version.
License
MIT
Project details
Release history Release notifications | RSS feed
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 shevchenko-1.0.0.tar.gz.
File metadata
- Download URL: shevchenko-1.0.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e509078ba24985ca021cf8bf8abce7d49c5e8ded4ab3cc6709af6a3da30edbea
|
|
| MD5 |
61680e34f1b3c33de6afc57c2412d056
|
|
| BLAKE2b-256 |
645da02267a4b828731bd6453efca3b6874e541d4789fcbdb3bb6cac13e50144
|
File details
Details for the file shevchenko-1.0.0-py3-none-any.whl.
File metadata
- Download URL: shevchenko-1.0.0-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a8060fb278ef43114fca385eaad3e28f79eb78fce8af3ef7f043277e5cbb2a6
|
|
| MD5 |
ac88c0701255b3ddfa1e280c9de1d160
|
|
| BLAKE2b-256 |
68ea5551ed33a541a243ddf465cc2268cea69c15a897acc8f1b7fdc96f54518a
|