Language Identification
Introduction
Automatically identifies the language of input text and returns the corresponding ISO language code. Aidge's Language Identification is optimized for short e-commerce texts, such as product titles, search queries, and customer service chats. It is highly robust when processing texts that contain a mix of numbers, abbreviations, and brand names.
It covers 31 languages for query phrases and 35 languages for general scenarios, and supports synchronous calls.
Use cases:
Search query routing: Route queries in multiple languages to the appropriate search engine after identification.
Customer service routing: Automatically route incoming conversations to customer service agents or translation bots based on the visitor's language.
Pre-translation check: Identify the source language before calling the Text Translation service.
Multilingual content classification: Group mixed-language content, such as product reviews or descriptions, by language for subsequent semantic analysis.
Quick start
For complete instructions on request signing, SDK examples in languages like Java, Python, and Go, and online debugging, see the Language Detection API (OpenAPI Portal) in the Alibaba Cloud OpenAPI Developer Portal.
Request parameters
Parameter | Type | Required | Description |
| String | Yes | The source text to identify. For short texts such as titles or search queries, accuracy is generally stable for text longer than five characters. Identification may be unreliable for extremely short texts or those containing only symbols or numbers. |
| String | No | The default value is |
Response fields
Field | Type | Description |
| String | The business status code. A value of |
| Boolean | Indicates whether the call was successful. |
| String | The unique request ID. |
| String | The error message, returned only when the request fails. |
| String | The detected language code. For a list of supported languages, see the "Supported languages" section. |
| Number | The number of characters in the input text, used for billing verification. |
Examples
Request example
{
"SourceText": "This is a test",
"Scene": "query"
}Response example
{
"Code": "success",
"Message": "Success",
"Success": true,
"RequestId": "2157065A-D6C8-1F3E-A4D0-B1234567890",
"Data": {
"DetectedLanguage": "en",
"UsageMap": { "InputCharacterCount": 14 }
}
}Supported languages
The service supports 31 languages for query phrases and 35 languages for general scenarios. For a complete list of languages and their codes, see the "Supported Languages for Language Identification" section in Language Pair Mapping.
Best practices
Avoid unnecessary translations: Before you call the Text Translation service, identify the source language. If the
DetectedLanguageis the same as your target language, you can skip the translation step.Handle short text: For texts with three or fewer characters, or those that consist entirely of numbers or symbols, create an allowlist on the client side to bypass identification and fall back to a default language.
Distinguishing between Simplified and Traditional Chinese: This API can distinguish between
zhandzh-tw. If your downstream translation model does not supportzh-tw, you must perform the mapping on the client.Handle mixed-language text: The service returns the dominant language, which is the language with the largest proportion in the text. If you need to identify the language of each sentence, split the text into sentences on the client side and call the service for each sentence.
Error codes
Error code | Description |
|
|
| The input text triggered content moderation. |
| The free trial quota has been exhausted. |
| Internal server error. Please save the |
For a complete list of error codes, see Error Codes.
Limitations
Call mode: Synchronous. For details on queries-per-second (QPS) limits and timeout settings, see the documentation on rate limiting.
Billing: Charged by
InputCharacterCount(number of characters). For more information, see Billing for Translation Services.
Next steps
Text Translation -- Translate text after identifying the source language.
Text Correction -- Correct spelling errors in text before translation.