Python package to form Ukrainian names cases : 'Леся Українка' -- 'Лесі Українки' , 'Лесі Українці', 'Лесею Українкою' ... etc.
Project description
Lesya
Lesya is a simple Python package for declining Ukrainian personal names into Ukrainian grammatical cases (відмінки): NOMINATIVE, GENITIVE, DATIVE, ACCUSATIVE, INSTRUMENTAL, PREPOSITIONAL, and VOCATIVE (називний, родовий, давальний, знахідний, орудний, місцевий, кличний).
Usage example
The most common usage is to convert a name into all cases:
from lesya import Lesya
person = Lesya('Леся Українка')
print(person.nominative) # Леся Українка
print(person.genitive) # Лесі Українки
print(person.dative) # Лесі Українці
print(person.accusative) # Лесю Українку
print(person.instrumental) # Лесею Українкою
print(person.prepositional) # Лесі Українці
print(person.vocative) # Лесе Українко
You can also get a name in a specific case:
from lesya import Lesya
from lesya import CaseUA
person = Lesya('Тарас Григорович Шевченко')
print(person[CaseUA.DATIVE]) # Тарасу Григоровичу Шевченку
print(person[CaseUA.PREPOSITIONAL]) # Тарасові Григоровичу Шевченкові
print(person['орудний']) # Тарасом Григоровичем Шевченком
Double names support
Lesya works well with double last names:
from lesya import Lesya
person = Lesya('Іван Семенович Нечуй-Левицький')
print(person.forms)
# Output:
{
'називний': 'Іван Семенович Нечуй-Левицький',
'родовий': 'Івана Семеновича Нечуя-Левицького',
'давальний': 'Івану Семеновичу Нечуєві-Левицькому',
'знахідний': 'Івана Семеновича Нечуя-Левицького',
'орудний': 'Іваном Семеновичем Нечуєм-Левицьким',
'місцевий': 'Іванові Семеновичу Нечуєві-Левицькому',
'кличний': 'Іване Семеновичу Нечую-Левицький'
}
forms attribute
You can get all cases at once using the forms attribute. It returns a dictionary where the keys are case names (in lowercase Ukrainian), and the values are the corresponding declined names.
Foreign names support
Lesya supports foreign names. However, since it does not use an ML model to automatically detect a person's gender, it works better if you explicitly provide the gender:
from lesya import Lesya
from lesya import CaseUA
from lesya import Gender
person = Lesya('Джозеф Байден', gender='male')
print(person[CaseUA.DATIVE]) # Джозефу Байдену
print(person[CaseUA.PREPOSITIONAL]) # Джозефові Байденові
person = Lesya('Камала Гаріс', gender=Gender.FEMALE)
print(person[CaseUA.DATIVE]) # Камалі Гаріс
print(person[CaseUA.PREPOSITIONAL]) # Камалі Гаріс
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 lesya-0.0.7.tar.gz.
File metadata
- Download URL: lesya-0.0.7.tar.gz
- Upload date:
- Size: 541.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2ce91442f8b937f215492a0df79ac641e129bc3c3089d5535bf3a6f289c8da2
|
|
| MD5 |
7970a18bfc55df29f2ac9f64aecb04ab
|
|
| BLAKE2b-256 |
9879ae931bbb3337d252ac87ec5bb45f18b198100287a35740ed7e5c702b99fd
|
File details
Details for the file lesya-0.0.7-py3-none-any.whl.
File metadata
- Download URL: lesya-0.0.7-py3-none-any.whl
- Upload date:
- Size: 546.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46aa3cfd54d33f1b579cb39915f10c76b1cccc157c0cd460fe355e0e04723c4a
|
|
| MD5 |
467b7cb4afce8907ae91d672d96cb57a
|
|
| BLAKE2b-256 |
c7cdccb505c6a17f4f142945007393e56dff47b46856347ca3d712d302363ff2
|