Text Analytics Endpoints
Language Identifier
https://analytics.babelstreet.com/rest/v1/language
https://raw.githubusercontent.com/rosette-api/curl-examples/develop/examples/language.curl
Language Identifier identifies the language or languages of the input text. The endpoint returns a list of languages identified in descending order of confidence, so the first result is the best. Language Identifier can also detect different language regions in a multilingual document. When multilingual
is set to true
, it returns a list of language regions in addition to the whole-document results.
The input data may be in any of 364 language–encoding–script combinations, involving 56 languages, 48 encodings, and 18 writing scripts. The language identifier uses an n-gram algorithm to detect language. Each of the 155 built-in profiles contains the quad-grams (i.e., four consecutive bytes) that are most frequently encountered in documents in a given language, encoding, and script. The default number of n-grams is 10,000 for double-byte encodings and 5,000 for single-byte encodings.
When input text is submitted for detection, a similar n-gram profile is built based on that data. The input profile is then compared with all the built-in profiles (a vector distance measure between the input profile and the built-in profile is calculated). The pre-built profiles are then returned in ascending order by the (shortest) distance of the input from the pre-built profiles.
For all supported languages, the endpoint provides a different proprietary algorithm for detecting the language of short strings (140 characters or less).
Tip
If the endpoint is unable to detect a language, it returns Unknown (xxx).
Query Parameters
Name | Value | Description |
---|---|---|
output | rosette | Returns the response in ADM format. |
Note
All input parameters, including the text being analyzed and any relevant options, are defined in the request body.
Request
Name | Type | Description |
---|---|---|
| string | Text to process |
| string | URI to accessible content |
Notice
content
and contentUri
are mutually exclusive; only one can be specified per call.
Option | Type | Description | Default |
---|---|---|---|
| boolean | If true, detect regions in multilingual documents. In addition to the whole-document language identification results, it returns a list of language region results in descending order of confidence. | false |
| boolean | If true, language classification for North Korean and South Korean is enabled. | false |
{ "content": "string", "options": { "koreanDialects": false, "multilingual": false } }
Response
Language Identifier returns a confidence score with each language result, ranging from 0 to 1. You can use this score as a threshold for filtering out low-confidence results.
{ "languageDetections": [ { "language": "string", "confidence": number } ] }
Supported Languages
GET /language/supported-languages
Returns the list of supported languages and scripts for the endpoint, along with whether you have a license for the language.
Response
Field | Type | Description |
---|---|---|
| string | ISO 639 language code |
| string | Four-letter ISO-15924 script code |
| boolean | Indicates if you are licensed for this language |
{ "supportedLanguages": [ { "language": "string", "script": "string", "licensed": boolean } ] }
Language ( | Short Strings Support | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Albanian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Arabic ( | ✓ [a] | ||||||||||||||||||||||||||||||||||||||||||||||||
Bengali ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Bulgarian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Catalan ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Chinese: Simplified & Traditional ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Croatian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Czech ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Danish ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Dutch ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
English ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Estonian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Finnish ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
French ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
German ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Greek ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Gujarati ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Hebrew ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Hindi ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Hungarian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Icelandic ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Indonesian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Italian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Japanese ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Kannada ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Korean ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Korean (North) ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Korean (South) ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Kurdish ( | ✓ [a] | ||||||||||||||||||||||||||||||||||||||||||||||||
Latvian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Lithuanian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Macedonian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Malayalam ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Norwegian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Persian ( | ✓ [a] | ||||||||||||||||||||||||||||||||||||||||||||||||
Polish ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Portuguese ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Pashto ( | ✓ [a] | ||||||||||||||||||||||||||||||||||||||||||||||||
Romanian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Russian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Serbian ( | ✓ [e] | ||||||||||||||||||||||||||||||||||||||||||||||||
Slovak ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Slovenian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Somali ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Spanish ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Standard Malay ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Swedish ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Tagalog ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Tamil ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Telugu ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Thai ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Turkish ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Ukrainian ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Urdu ( | ✓ [a] | ||||||||||||||||||||||||||||||||||||||||||||||||
Uzbek ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
Vietnamese ( | ✓ | ||||||||||||||||||||||||||||||||||||||||||||||||
[a] Short-string support is only provided for Arabic script [b] The language endpoint also provides specialized support for English text in which case should be ignored. When processing such text, specify the English language code [c] North Korean ( [d] The language endpoint detects Cyrillic Serbian, but disables, by default, detection of Latin script Serbian. To enable detection of Serbian written in Latin script, set its weight to a positive number (such as 100) in the options when calling the endpoint. [e] The short-string algorithm supports Latin Script Serbian by default. |