Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python3 port of Petrovich, an inflector (and gender detector) for Russian anthroponyms

License

NotificationsYou must be signed in to change notification settings

petrovich/pytrovich

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pytrovich

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.

Python 3xPyPI versionDownloads

Installation

Should be as simple as that

pip install pytrovich

Usage

Inflection

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,"Ивановна"))# Ивановне

Gender detection

frompytrovich.detectorimportPetrovichGenderDetectordetector=PetrovichGenderDetector()print(detector.detect(firstname="Иван"))# Gender.MALEprint(detector.detect(firstname="Иван",middlename="Семёнович"))# Gender.MALEprint(detector.detect(firstname="Арзу",middlename="Лутфияр кызы"))# Gender.FEMALE

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. ifpytrovich fails onPetrovichDeclinationMaker creation,one may consider downloadingrules.json directly frompetrovich-rules repo as a fix (please create an issue if that actually happens).

How to cite

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},}

More info

For more information on the project please refer to otherpetrovich repos.

TODO

  • efficiency was not a top priority, the time has come for faster algorithms, RegEx and data structures
  • evaluation based onpetrovich-eval

License

This project is available under MIT license.

About

Python3 port of Petrovich, an inflector (and gender detector) for Russian anthroponyms

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp