Language Detection

language(data, {[apiKey]: String, [privateCloud]: String})

Current Version: 2

Arguments

data – String | List – required – text to be analyzed
[apiKey] – String – optional – your indico API key
[privateCloud] – String – optional – your private cloud subdomain
[v or version] – Integer – optional (defaults to 2) – specify model version
[top_n] – Integer – optional (defaults to 3) – only return this many of the most likely languages
[threshold] – Float – optional (defaults to .0) – only return languages with likelihood greater than this number
[relative] – Boolean (defaults to False) – optional – when False, the probabilities of all languages sum to 1, when True, language probabilities are independent and are not constrained to sum to 1.

Output

This function will return a dictionary with 33 key-value pairs. These key-value pairs represent the likelihood that the analyzed text is written in each of the 33 possible languages. The keys in the dictionary are strings containing the language names and the values are the probabilities that the analyzed text is written in each language.
Values less than 0.05 indicate that it is very unlikely the text is written in the corresponding language.

Complete List of Languages:
Arabic (ar), Bulgarian (bg), Chinese (ch), Czech (cs), Danish (da), Dutch (nl), English (en), Esparanto (eo), Farsi (fa), Finnish (fi), French (fr), German (de), Greek (el), Hebrew (he), Hungarian (hu), Indonesian (id), Italian (it), Japanese (ja), Korean (ko), Latin (la), Lithuanian (lt), Norwegian (no), Polish (pl), Portuguese (pg), Romanian (ro), Russian (ru), Slovak (sk), Spanish (es), Swedish (sv), Tagalog (tl), Thai (th), Turkish (tr), Vietnamese (vi)

# single output
{
    'swedish': 0.00004324968926091062,
    'lithuanian': 0.007702528578033991,
    'vietnamese': 0.0002575132225946431,
    '... 33 languages omitted ...',
    'english': 0.2071775132225946431,
    'chinese': 0.008160047807935744,
    'arabic': 0.00015069427192724994
}

# batch output
[
    {
        'swedish': 0.00004324968926091062,
        'lithuanian': 0.007702528578033991,
        'vietnamese': 0.0002575132225946431,
        '... 33 languages omitted ...',
        'english': 0.2071775132225946431,
        'chinese': 0.008160047807935744,
        'arabic': 0.00015069427192724994
    },
    {
        'swedish': 0.0020400125677411812,
        'lithuanian': 0.010790799662278016,
        'vietnamese': 0.002072348777350773,
        ... 33 languages omitted ...,
        'english': 0.0012626451944395167,
        'chinese': 0.004772236821288096,
        'arabic': 0.22969626130844248
    }
]

Example

var indico = require('indico.io');
indico.apiKey =  'YOUR_API_KEY';

var response = function(res) { console.log(res); }
var logError = function(err) { console.log(err); }

// single example
indico.language("How are you?")
  .then(response)
  .catch(logError);

// batch example
var batchInput = [
    "How are you?",
    "¿Cómo estás?"
];
indico.language(batchInput)
  .then(response)
  .catch(logError);