Predict Language
Table of Contents
Description
The zoho.ai.predictLanguage task identifies the language of the given piece of text.
- The prediction results may not be accurate, which is also the case with any AI prediction. However, we are working on improving this.
- The prediction results are dynamic. The same script may produce different outcomes at different times based on how much the machine has learned.
Syntax
<response> = zoho.ai.predictLanguage(<sentence>);
where:
Params | Data type | Description |
<response> | KEY-VALUE | Specifies the predicted language, the prediction accuracy of the result, and the status of the executed task. |
<sentence> | TEXT | Specifies the piece of text whose language needs to be identified |
Example
The following script identifies the language of the text - Hai tout, comment ça va?.
response = zoho.ai.predictLanguage("Hai tout, comment ça va?");
where:
response
"Hai tout, comment ça va?"
Response Format
Success Response
The success response will be return in the following format:
{
"data": {
"items": [
{
"predictionProbabilities": {
"fr": 0.9999907117029719
},
"queryValue": "Hai tout, comment ça va?"
}
]
},
"message": "OK",
"status": 200
}
//Store the predicted languages from the response in a collection. predicted_language = response.getJson("data").getJSON("items").getJSON("predictionProbabilities").toCollection(); //Sort the predicted probablity values in descending and get the highest value. highest_probablity = predicted_language.values().sort(false).get(0); //Fetch the language key by matching the highest probablity value. info predicted_language.getKey(highest_probablity);
Failure Response
The failure response for an empty input text will be returned in the following format:
{ "message":"EMPTY_VALUE_NOT_ALLOWED", "status":400 }