Text.Language.Classifier behaviour (Text v0.2.0) View Source

A behaviour definition module for language classifiers.

A langauge classifier correlates supplied natural language text against a vocabulary and returns a score indicating how closely the supplied text matches the vocabulary.

Link to this section Summary

Types

A list of 2-tuples of the form {language, number}

t()

A classifier is a module that implements the Text.Language.Classifier behaviour.

A list mapping an n-gram as a charlist to a Text.Ngram.Frequency struct

Callbacks

Sorts the classifier scores from all languages in order or correlation.

Returns the classifier score for one language.

Link to this section Types

Specs

frequency_list() :: [Text.frequency_tuple(), ...]

A list of 2-tuples of the form {language, number}

Specs

t() :: module()

A classifier is a module that implements the Text.Language.Classifier behaviour.

Specs

text_ngrams() :: %{required(charlist()) => Text.Ngram.Frequency.t()}

A list mapping an n-gram as a charlist to a Text.Ngram.Frequency struct

Link to this section Callbacks

Link to this callback

order_scores(frequency_list)

View Source

Specs

order_scores(frequency_list()) :: frequency_list()

Sorts the classifier scores from all languages in order or correlation.

Link to this callback

score_one_language(language, text_ngrams, vocabulary)

View Source

Specs

score_one_language(Text.language(), text_ngrams(), Text.vocabulary()) ::
  frequency_list()

Returns the classifier score for one language.

A classifier correlates how closely a supplied string (encoded into n-grams) matches against a given langauge profile implemented as a vocabulary.

See Text.Language.Classifier.NaiveBayesian for an example.