Home

Awesome

petrovic_elixir

petrovich

test Coverage Status Hex Version License

Elixir library to inflect Russian first, last, and middle names.

Installation

def deps do
  [
    {:petrovich_elixir, "~> 1.0"}
  ]
end

Usage

Do I need to know Russian to use it?

Yes, you will need some basic Russian knowledge to work with this library. You need to understand how grammatical cases work in Russian language.

Inflection

Petrovich.firstname!("Александр", :accusative)
# => Александра

Petrovich.middlename!("Сергеевич", :accusative)
# => Сергеевича

Petrovich.lastname!("Пушкин", :accusative, :male)
# => Пушкина

Gender detection

alias Petrovich.Detector

Detector.detect_gender("Александр", :firstname)
# => {:ok, "male"}

Configuration

You will need to add these lines into your config.exs:

config :petrovich_elixir,
  rules_path: "rules/rules.json",
  gender_path: "rules/gender.json",
  json_codec: Jason

You can swap our default (Jason) codec to any of your choice.

Rules

This package uses petrovich-rules as the source for all transformations. If you ever experience wrong result or other issues with the data itself, please open an issue here.

License

MIT. See LICENSE for details.