petrovich_elixir v1.0.0 Petrovich.Detector View Source

Guesses the gender by person's name.

Link to this section Summary

Functions

Detects a gender by name.

Link to this section Functions

Link to this function

detect_gender(name, type) View Source
detect_gender(String.t(), atom()) :: {:ok, String.t()} | :error

Detects a gender by name.

This function receives two arguments:

  1. name raw person's name in nomenative case
  2. type which shows what part of person's name it is

You can use any of these values as type:

[:firstname, :middlename, :lastname]

On success it returns a tuple {:ok, "detected_gender"}. Or :error in cases when it is impossible to detect gender.

Examples

iex> Detector.detect_gender("Игорь", :firstname)
{:ok, "male"}

iex> Detector.detect_gender("Саша", :firstname)
{:ok, "androgynous"}

iex> Detector.detect_gender("123", :firstname)
:error