Text and language processing for Elixir.

This is the library's entry-point module. It exposes two convenience functions — ngram/2 (delegated to Text.Ngram) for n-gram generation and pluralize_noun/2 for English pluralisation — while the bulk of the functionality lives in focused submodules:

See the README and guides for a capability overview.

Summary

Types

A language as a BCP-47 string

Types

language()

@type language() :: String.t()

A language as a BCP-47 string

Functions

ngram(text, n)

See Text.Ngram.ngram/2.

pluralize_noun(word, options \\ [])

Pluralize a noun.

Arguments

  • word is any English noun.

  • options is a keyword list of options.

Options

  • :mode is either :modern or :classical. The default is :modern.

  • :language is the inflection module to be used. The default and only option is Text.Inflect.En.

Returns

  • A String representing the pluralized noun.

Notes

mode when :classical applies pluralization on latin nouns used in english but with latin suffixes.

Examples

iex> Text.pluralize_noun "Major general"
"Major generals"

iex> Text.pluralize_noun "fish"
"fish"

iex> Text.pluralize_noun "soliloquy"
"soliloquies"

iex> Text.pluralize_noun "genius", mode: :classical
"genii"

iex> Text.pluralize_noun "genius"
"geniuses"

iex> Text.pluralize_noun "platypus", mode: :classical
"platypodes"

iex> Text.pluralize_noun "platypus"
"platypuses"