Choose where you’d like to start

Predict Language

Description

The zoho.ai.predictLanguage task identifies the language of the given piece of text.

Note: 
  • 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:

ParamsData typeDescription

<response>

KEY-VALUE

Specifies the predicted language, the prediction accuracy of the result, and the status of the executed task.
Note: You can find the list of supported languages here.

<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
The KEY-VALUE response that represents the predicted language, the prediction accuracy of the result, and the status of the executed task. Here, the language returned is French (fr).
"Hai tout, comment ça va?"
The TEXT that represents the piece of text whose language needs to be identified.

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
     }
Note: To fetch the most probable predicted language from the response, use the following script:
//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  }
 

Related Links

Get Started Now

Execute