Skip to content

Golang implementation of the Petrovich project(Russian anthroponyms inflector)

License

Notifications You must be signed in to change notification settings

yalosev/petrovich

Repository files navigation

Petrovich

Golang port of petrovich library(https://github.com/petrovich) which inflects Russian names to a given grammatical case

GoDoc Go Report Card

Installation

go get github.com/yalosev/petrovich

Usage

package main

import (
    "fmt"
    "github.com/yalosev/petrovich"
)

func main() {
	ivan := petrovich.Person{
		FirstName: "Иван",
		MiddleName: "Иванович",
		LastName: "Иванов",
		Gender: petrovich.Male,
	}
	result := petrovich.Transform(ivan, petrovich.Genitive)
	
	fmt.Println(result) // Output: Иванова Ивана Ивановича
	fmt.Println(result.Short()) // Output: Иванова И. И.

    // OR
    petr := petrovich.NewPerson("Басов", "Петр", "Андреевич") 

    fmt.Println(petrovich.Transform(petr, petrovich.Prepositional)) // Output: Басове Петре Андреевиче
}

Possible 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 Предложный О ком?

About

Golang implementation of the Petrovich project(Russian anthroponyms inflector)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages