pytrovich: a Python port of an inflector for Russian anthroponyms developed by petrovich team: https://github.com/petrovich
Project description
pytrovich is a Python 3.6+ port of petrovich library which inflects Russian names to a given grammatical case. It supports first names, last names and middle names inflections.
petrovich-java was the main inspiration.
Installation
Should be as simple as that
pip install pytrovich
Usage
from pytrovich.enums import NamePart, Gender, Case
from pytrovich.maker import PetrovichDeclinationMaker
maker = PetrovichDeclinationMaker()
print(maker.make(NamePart.FIRSTNAME, Gender.MALE, Case.GENITIVE, "Иван")) # Ивана
print(maker.make(NamePart.LASTNAME, Gender.MALE, Case.INSTRUMENTAL, "Иванов")) # Ивановым
print(maker.make(NamePart.MIDDLENAME, Gender.FEMALE, Case.DATIVE, "Ивановна")) # Ивановне
Custom rule file
You can replace default rules file with some custom one. Only JSON format is supported.
maker = PetrovichDeclinationMaker("/path/to/custom/rules.file.json")
E.g. if pytrovich
fails on PetrovichDeclinationMaker
creation,
one may consider downloading rules.json
directly from
petrovich-rules repo as a fix.
More info
For more info please refer to other petrovich repos.
TODO
- grammatical gender detection (given the name)
How to cite us
section
License
This project is available under MIT license.
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
Hashes for pytrovich-0.0.1.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3790706a938339c1f83d9121654f61ebc798393e4f93ee5c6c2e76ab171d19f |
|
MD5 | a0abc8422c2f1c793b4a177f0436b9ef |
|
BLAKE2b-256 | acaa51627c32885110b460826df83abd9eef33c25c65d227be1f1ba7ec929429 |