DetectDominantLanguage
Determines the dominant language of the input text. For a list of languages that Amazon Comprehend can detect, see Amazon Comprehend Supported Languages.
Request Syntax
{
"Text": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- Text
-
A UTF-8 text string. The string must contain at least 20 characters. The maximum string size is 100 KB.
Type: String
Length Constraints: Minimum length of 1.
Required: Yes
Response Syntax
{
"Languages": [
{
"LanguageCode": "string",
"Score": number
}
]
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- Languages
-
Array of languages that Amazon Comprehend detected in the input text. The array is sorted in descending order of the score (the dominant language is always the first element in the array).
For each language, the response returns the RFC 5646 language code and the level of confidence that Amazon Comprehend has in the accuracy of its inference. For more information about RFC 5646, see Tags for Identifying Languages
on the IETF Tools web site. Type: Array of DominantLanguage objects
Errors
For information about the errors that are common to all actions, see Common Errors.
- InternalServerException
-
An internal server error occurred. Retry your request.
HTTP Status Code: 500
- InvalidRequestException
-
The request is invalid.
HTTP Status Code: 400
- TextSizeLimitExceededException
-
The size of the input text exceeds the limit. Use a smaller document.
HTTP Status Code: 400
Examples
Detect dominant language
If the input text is "Bob lives in Seattle. He is a software engineer at Amazon.", the operation returns the following:
{ "Languages": [ { "LanguageCode": "en", "Score": 0.9774383902549744 }, { "LanguageCode": "de", "Score": 0.010717987082898617 } ] }
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: