Skip to main content

A Python library for declension of personal names in Serbian

Project description

deklinacija

A Python library for declension of personal names in Serbian, with support for both Cyrillic and Latin scripts, and last names.

Installation

The source code is currently hosted on GitHub: https://github.com/urelja/deklinacija

The latest binary versions are hosted on the Python Package Index (PyPI): https://pypi.org/project/deklinacija/

pip install deklinacija

Usage

Simply import the package. It is recommended to set the alias to dek.

import deklinacija as dek

To decline names, all you have to do is to call the appropriate function for the grammatical case you want to use, and specify the name and the gender parameter. The name parameter must be a string, can have either Latin or Cyrillic characters (automatically detected), and can contain uppercase or lowercase letters (the script respects the capitalisation of the name and will capitalise the added suffixes according to the last character's capitalisation, see vokativ2 below). You can also input a full name (with a first name and a last name, multiple last names are supported too, separated with a whitespace character) and the script will change the name accordingly.

The functions in this example return a string.

import deklinacija as dek

genitiv = dek.genitiv("Velja","male") #Velje
genitiv2 = dek.genitiv("Velja Petrović","male") #Velje Petrovića
dativ = dek.dativ("Jana","female") #Jani
dativ2 = dek.dativ("Jana Paunovska","female") #Jani Paunovskoj
akuzativ = dek.akuzativ("Петар","male") #Петра
akuzativ2 = dek.akuzativ("Петар Петровић","male") #Петра Петровића
vokativ = dek.vokativ("Predrag","male") #Predraže
vokativ2 = dek.vokativ("PREDRAG JANKOVIĆ","male") #PREDRAŽE JANKOVIĆU
instrumental = dek.instrumental("Uroš","male") #Urošem
instrumental2 = dek.instrumental("Uroš Konstantinović","male") #Urošem Konstantinovićem
lokativ = dek.lokativ("Lana","female") #Lani
lokativ = dek.lokativ("Lana Petrović","female") #Lani Petrović

print(f"Zdravo, {vokativ}! Dobio si zahtev za prijateljstvo od {genitiv2}.") 
#Zdravo Predraže! Dobio si zahtev za prijateljstvo od Velje Petrovića.
#Translation: Hello Predrag! You have received a friend request from Velja Petrović.

You can also immediatelly decline a name through all grammatical cases by calling the declineAll() function.

The declineAll() function returns a dictionary, where keys are the grammatical cases.

import deklinacija as dek

name = dek.declineAll("Nikola","male") 
#{'nominativ': 'Nikola', 'genitiv': 'Nikole', 'dativ': 'Nikoli', 'akuzativ': 'Nikolu', 
#'vokativ':'Nikola', 'instrumental': 'Nikolom', 'lokativ': 'Nikoli'}

print("Dali ste poklon",name['dativ']) 
#Dali ste poklon Nikoli
#Translation: You have given a gift to Nikola

Todo

The following features are on the roadmap:

  • Possessive forms

Attribution

Vokativi by Startit is licensed under CC BY 4.0 / Modifications: converted to Cyrillic and filtered out names longer than 4 characters

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

deklinacija-1.5.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

deklinacija-1.5.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file deklinacija-1.5.2.tar.gz.

File metadata

  • Download URL: deklinacija-1.5.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for deklinacija-1.5.2.tar.gz
Algorithm Hash digest
SHA256 2f5cfc333c913eda8f4537e73e0f70bd13e3af45ee7ea36a55ede29f1ca3479f
MD5 c12dac0e79d8a19f80a61dde29b854bf
BLAKE2b-256 ddc9d85cdce3850ea83233ab70fcafc185112734f40467319236f6eecf773081

See more details on using hashes here.

File details

Details for the file deklinacija-1.5.2-py3-none-any.whl.

File metadata

  • Download URL: deklinacija-1.5.2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for deklinacija-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82c0474de44722fbfbe2c9a6906b8d4a52a5a7f0155cf3523b30708a55f787ec
MD5 b5032564066f1e66bd78c0133694130b
BLAKE2b-256 d5e284519c78035016804e76a1ac7072229e45690eda9586eef19c9867813679

See more details on using hashes here.

Supported by

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