RWS Logo
Show / Hide Table of Contents

Language Detections

Create a language detection

Example Request:

curl "https://controller-host:8001/api/v2/language-detections" \
	-X POST \
	-u u_jsmith@example.com_u0VmztKJrwqf: \
	-d input="VGhpcyBpcyBlbmdsaXNoIHRleHQgZm9sbG93ZWQgYnkgc29tZSBzcGFuaXNoIHRleHQuCkFzIGh1bmRyZWRzIG9mIHRob3VzYW5kcyBvZiBwZW9wbGUgcG90ZW50aWFsbHkgaW4gdGhlIHBhdGggb2YgSHVycmljYW5lIE1hdHRoZXcgZmxlZCBpbmxhbmQgV2VkbmVzZGF5LCBub3QgZXZlcnlvbmUgd2FzIGV2YWN1YXRpbmcuCgpJbiBDaGFybGVzdG9uLCBTb3V0aCBDYXJvbGluYSwgd2hpY2ggbGlrZWx5IHdpbGwgc2VlIHRoZSBwb3dlcmZ1bCBzdG9ybSdzIGltcGFjdCB0aGlzIHdlZWtlbmQsIHNvbWUgcGVvcGxlIHdlcmUgYm9hcmRpbmcgdXAgYnVzaW5lc3Nlcy4KQ2hlcnlsIFF1aW5uIHRvbGQgQ05OJ3MgU3RlcGhhbmllIEVsYW0gc2hlIGlzIHBsYW5uaW5nIHRvIGh1bmtlciBkb3duLgoKQ29uIHVuIHRvdGFsIGRlIG3DoXMgZGUgc2lldGUgbWludXRvcyBkZSBkdXJhY2nDs24sIGZ1ZSBlbiBzdSB0aWVtcG8gbGEgY2FuY2nDs24gbcOhcyBsYXJnYSBkZSBsYSBoaXN0b3JpYSBlbiBlc3RhciBlbiBlbCB0b3AgMTAgZGUgbGFzIGxpc3RhcyBicml0w6FuaWNhcyBkZSBzZW5jaWxsb3MuIFRhbWJpw6luIHBhc8OzIG51ZXZlIHNlbWFuYXMgY29tbyBuLgoK" \
	--data-urlencode inputFormat="text/plain"

Example Response:

{
    "encoding": "UTF-8",
    "languages": [
        {
            "code": "eng",
            "languageTag": "en",
            "name": "English",
            "score": 0.6
        },
        {
            "code": "spa",
            "languageTag": "es",
            "name": "Spanish",
            "score": 0.39
        }
    ],
    "scripts": [
        {
            "code": "Latn",
            "name": "Latin",
            "percent": 80.1
        },
        {
            "code": "Zyyy",
            "name": "Common",
            "percent": 19.9
        }
    ]
}

Create a synchronous job that attempts to detect the language(s) and script(s) of an input string.

HTTP Request

POST /api/v2/language-detections

Request Parameters

Name Type Description Default Value
input string Base64-encoded and URL-encoded content to submit for language detection
inputFormat string Format of input document (see table of possible input formats)
encoding (optional) string Encoding of source content (see list of supported character encodings) UTF-8

Returns

Returns the detected language(s) and script(s) as a LanguageDetection object with the following attributes:

Name Type Description
encoding string Source content encoding
languages array of objects List of up to 3 detected languages as an array of DetectedLanguage objects (expanded below)
→ code string Edge code of detected language (see language codes table)
→ languageTag string IETF language tag of detected language (see language codes table)
→ name string Full name of detected language
→ score float A value between 0 and 1; the closer the value is to 1, the greater the association between the detected language and source content
scripts array of objects List of all detected scripts as an array of DetectedScript objects (expanded below)
→ code string ISO-15924 code of detected script (see script codes table)
→ name string Name of detected script
→ percent float Percentage of source content using specific script
In this page
Back to top