- Notifications
You must be signed in to change notification settings - Fork1
Python3 port of Petrovich, an inflector (and gender detector) for Russian anthroponyms
License
petrovich/pytrovich
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
pytrovich is a Python 3.6+ port ofpetrovich library which inflects Russian namesto a given grammatical case. It supports first names, last names and middle names inflections. Since version 0.0.2,gender detection is also available.
petrovich-java was the main inspiration.
The alternative (earlier) port:Petrovich (@alexeyev was not aware of it at the time of portingpetrovich to Python).The only meaningful difference we have found is that it does not support gender detection.
Should be as simple as that
pip install pytrovich
frompytrovich.enumsimportNamePart,Gender,Casefrompytrovich.makerimportPetrovichDeclinationMakermaker=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,"Ивановна"))# Ивановне
frompytrovich.detectorimportPetrovichGenderDetectordetector=PetrovichGenderDetector()print(detector.detect(firstname="Иван"))# Gender.MALEprint(detector.detect(firstname="Иван",middlename="Семёнович"))# Gender.MALEprint(detector.detect(firstname="Арзу",middlename="Лутфияр кызы"))# Gender.FEMALE
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. ifpytrovich fails onPetrovichDeclinationMaker creation,one may consider downloadingrules.json directly frompetrovich-rules repo as a fix (please create an issue if that actually happens).
Not neccessary, but greatly appreciated, if you use this work.
@misc{Pytrovich, title = {{petrovich/pytrovich: Python3 port of Petrovich, an inflector for Russian anthroponyms}}, year = {2020}, url = {https://github.com/petrovich/pytrovich}, language = {english},}For more information on the project please refer to otherpetrovich repos.
- efficiency was not a top priority, the time has come for faster algorithms, RegEx and data structures
- evaluation based onpetrovich-eval
This project is available under MIT license.
About
Python3 port of Petrovich, an inflector (and gender detector) for Russian anthroponyms
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
