Class: Language

Language()

Class for managing languages. The main purpose is to guess the language of an utterance, but it also manage a list of languages indexed by both ISOs.

Constructor

new Language()

Constructor of the class.
Source:

Methods

buildData()

Given the data of the languages, build the indexes.
Source:

guess(utterance, allowList, limit) → {Array.<Object>}

Given an utterance, an allow list of iso codes and the limit of results, build an array of languages scored. The allow list and the limit are optional.
Parameters:
Name Type Description
utterance String Utterance wich we want to guess the language.
Allow list Array.<String> Allow list of accepted languages.
limit Number Limit of results.
Source:
Returns:
Array of guesses.
Type
Array.<Object>

guessBest(utterance, allowList) → {Object}

Given an utterance, an allow list of iso codes and the limit of results, return the language with the best score. The allow list is optional.
Parameters:
Name Type Description
utterance String Utterance wich we want to guess the language.
Allow list Array.<String> Allow list of accepted languages.
Source:
Returns:
Best guess.
Type
Object

transformAllowList(allowList) → {Array.<String>}

Given an allow list, iterates each language to transform from iso2 to iso3 each code.
Parameters:
Name Type Description
Allow list Array.<String> Array of language codes in iso3 or iso2
Source:
Returns:
Allow list forced to iso3.
Type
Array.<String>