/petrovich-java

Library to inflect Russian first, last, and middle names. Java implementation of Petrovich.

Primary LanguageJavaMIT LicenseMIT

Petrovich petrovich-java

petrovich-java is library which inflects Russian names to given grammatical case. It supports first names, last names and middle names inflections.

petrovich-java is Java implementation of Petrovich ruby gem.

[Build Status] (https://travis-ci.org/petrovich/petrovich-java)

Building

mvn -DskipTests=true clean package install

Usage

PetrovichDeclinationMaker maker = PetrovichDeclinationMaker.getInstance();

maker.make(NamePart.FIRSTNAME, Gender.MALE, Case.GENITIVE, "Иван");     //Ивана
maker.make(NamePart.LASTNAME, Gender.MALE, Case.INSTRUMENTAL, "Иванов");   //Ивановым
maker.make(NamePart.MIDDLENAME, Gender.FEMALE, Case.DATIVE, "Ивановна");   //Ивановне

Also you can use more convenient syntax

PetrovichDeclinationMaker maker = PetrovichDeclinationMaker.getInstance();

maker.male.firstname().toGenitive("Иван");      //"Ивана"
maker.male.lastname().toInstrumental("Иванов");     //"Ивановым"
maker.female.middlename().toDative("Ивановна");     //"Ивановне"

Custom rule file

You can replace default rules file with some custom one. Only JSON format supported by now.

PetrovichDeclinationMaker maker = PetrovichDeclinationMaker.getInstance("/path/to/custom/rules.file.json");

Accuracy

You can read about accuracy statistics in petrovich-ruby project front page

License

This project available under MIT license