Skip to main content

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lesya-0.0.8.tar.gz (543.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lesya-0.0.8-py3-none-any.whl (546.8 kB view details)

Uploaded Python 3

File details

Details for the file lesya-0.0.8.tar.gz.

File metadata

  • Download URL: lesya-0.0.8.tar.gz
  • Upload date:
  • Size: 543.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for lesya-0.0.8.tar.gz
Algorithm Hash digest
SHA256 dfd896206562bf90502853dec23f2a625ccbc7913c6267b064bfa2b644d30cdb
MD5 b4b1e1c0133e592e4d5a0b7c07445979
BLAKE2b-256 b513c0bc2cd67ed6264a5e0f31b43c0b29b4375057bff1f14e472e41e43c9e5d

See more details on using hashes here.

File details

Details for the file lesya-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: lesya-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 546.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for lesya-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a5111f250a4ac9748eeef3448254f05e085fa93e0cbe6dce8a5006695160d148
MD5 d44f8d75366dde52e0c9c1bcc155bc2b
BLAKE2b-256 98026aa9917cd0fa533b10da4c8fcc942354666cf7f885042ebea23367098b6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page