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.9.tar.gz (544.0 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.9-py3-none-any.whl (547.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lesya-0.0.9.tar.gz
Algorithm Hash digest
SHA256 a4098859cf32adf492643b38594d9706637fb1747f47a210397c3f0014789213
MD5 d004998bf630bacca1e5b98257035202
BLAKE2b-256 98d4fc7bd7331e6cebc46eac595f402bac9262079814286cc8beb7c8524c983c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lesya-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 171447698284e00dab2290f3ef2715cc7c8d771f0717125f39a1efec2fda140e
MD5 dab3f47c0d342335ce298cd733876a2f
BLAKE2b-256 b0c29a0126fd38d00ae6c423b0ea15553e4c83f581a4e4f059f6332de7d8811e

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