README

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

Documentation

Overview

    Package petrovich provides methods to inflect Russian first, last, and middle names.

    This is the Go port of https://github.com/petrovich. All implementations use common rules from https://github.com/petrovich/petrovich-rules.

    Usage:

    n := petrovich.FirstName("Кузьма", petrovich.Male, petrovich.Genitive)
    fmt.Print(n) // "Кузьмы"
    
    n = petrovich.LastName("Петров-Водкин", petrovich.Male, petrovich.Prepositional)
    fmt.Print(n) // "Петрове-Водкине"
    

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func FirstName

    func FirstName(name string, g Gender, c Case) string

      FirstName inflects first name depending on the given gender and case.

      func LastName

      func LastName(name string, g Gender, c Case) string

        LastName inflects last name depending on the given gender and case.

        func MiddleName

        func MiddleName(name string, g Gender, c Case) string

          MiddleName inflects middle name depending on the given gender and case.

          Types

          type Case

          type Case int
          const (
          	Nominative Case = -1 + iota
          	Genitive
          	Dative
          	Accusative
          	Instrumental
          	Prepositional
          )

          type Gender

          type Gender int
          const (
          	Androgynous Gender = iota
          	Male
          	Female
          )

          Directories

          Path Synopsis