Whatlangex (whatlangex v0.3.0)

NIF bindings for Whatlang, a natural language detection library written in Rust.

Summary

Functions

Get the full language English name from language code.

Get the full language native name from language code.

Detect the language of the given sentence.

Functions

code_to_eng_name(code)

@spec code_to_eng_name(String.t()) :: String.t() | nil

Get the full language English name from language code.

Examples

iex> code_to_eng_name("fra")
"French"

iex> code_to_eng_name("abc")
nil

code_to_name(code)

@spec code_to_name(String.t()) :: String.t() | nil

Get the full language native name from language code.

Examples

iex> code_to_name("fra")
"Français"

iex> code_to_name("abc")
nil

detect(sentence)

@spec detect(String.t()) :: Whatlangex.Detection.t() | nil

Detect the language of the given sentence.

Examples

iex> detect("This is a cool sentence.")
%Whatlangex.Detection{lang: "eng", script: "Latin", confidence: 0.47970281937238757}

iex> detect("")
nil