Skip to content
Golang port of Petrovich - an inflector for Russian anthroponyms.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
rules @ e5e673c Update rules Oct 12, 2017
rules-generator Switch to own rules generator Dec 21, 2016
.gitmodules
.travis.yml Add Travis CI config file Dec 20, 2016
LICENSE
README.md
go.mod Migrate to Go modules Dec 11, 2018
go.sum Migrate to Go modules Dec 11, 2018
petrovich.go Fix typo Dec 21, 2016
petrovich.png
petrovich_test.go Add test for non-existent rule Oct 12, 2017
rules.go Switch to own rules generator Dec 21, 2016
rules_generated.go Update rules Oct 12, 2017

README.md

Petrovich

Petrovich is the library which inflects Russian names to given grammatical case.

This is the Go port of https://github.com/petrovich.

GoDoc Build Status Coverage Status Go Report Card

Installation

go get github.com/striker2000/petrovich

Usage

All functions takes three arguments: name in nominative case, gender and grammatical case.

import "github.com/striker2000/petrovich"

n := petrovich.FirstName("Кузьма", petrovich.Male, petrovich.Genitive)
fmt.Print(n) // "Кузьмы"

n = petrovich.MiddleName("Сергеевич", petrovich.Male, petrovich.Instrumental)
fmt.Print(n) // "Сергеевичем"

n = petrovich.LastName("Петров-Водкин", petrovich.Male, petrovich.Prepositional)
fmt.Print(n) // "Петрове-Водкине"

Valid values for gender are petrovich.Androgynous, petrovich.Male and petrovich.Female.

Full list of grammatical cases is in the table below.

Case Case (in Russian) Question (in Russian)
petrovich.Nominative Именительный Кто?
petrovich.Genitive Родительный Кого?
petrovich.Dative Дательный Кому?
petrovich.Accusative Винительный Кого?
petrovich.Instrumental Творительный Кем?
petrovich.Prepositional Предложный О ком?
You can’t perform that action at this time.