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, whitelist, limit) → {Array.<Object>}

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

guessBest(utterance, whitelist) → {Object}

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

transformWhitelist(whitelist) → {Array.<String>}

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