Skip to main content

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) # Лесе Українко

When printing the Lesya object, you will get just nominative case:

person = Lesya('Дмитро Андрійович Устинов')
print(person) # Дмитро Андрійович Устинов

You can also get a name in a specific case with square brackets:

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]) # Камалі Гаріс

Metadata

Release files for lesya 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lesya 0.0.9
File Size Uploaded Provenance Actions
lesya-0.0.9.tar.gz 544.0 kB Without provenance Details for lesya-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lesya 0.0.9
File Interpreter ABI Platform Actions
lesya-0.0.9-py3-none-any.whl Python 3 none any Details for lesya-0.0.9-py3-none-any.whl

Total release size: 1.1 MB

Release files / lesya-0.0.9.tar.gz

Download URL lesya-0.0.9.tar.gz
Size 544.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a4098859cf32adf492643b38594d9706637fb1747f47a210397c3f0014789213
BLAKE2b-256 checksum
How to use checksums
98d4fc7bd7331e6cebc46eac595f402bac9262079814286cc8beb7c8524c983c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release files / lesya-0.0.9-py3-none-any.whl

Download URL lesya-0.0.9-py3-none-any.whl
Size 547.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
171447698284e00dab2290f3ef2715cc7c8d771f0717125f39a1efec2fda140e
BLAKE2b-256 checksum
How to use checksums
b0c29a0126fd38d00ae6c423b0ea15553e4c83f581a4e4f059f6332de7d8811e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Security for lesya 0.0.9

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page