Skip to main content

pytrovich: a Python port of an inflector for Russian anthroponyms developed by petrovich team: https://github.com/petrovich

Project description

Pytrovich

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


Download files

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

Source Distribution

pytrovich-0.0.1.post2.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distribution

pytrovich-0.0.1.post2-py3-none-any.whl (19.7 kB view hashes)

Uploaded Python 3

Supported by

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