Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get multiple variations from Google Translate API

When we make a query to Translate API

https://translation.googleapis.com/language/translate/v2?key=$API_KEY&q=hello&source=en&target=e

I only get 1 result in :

{
  "data": {
    "translations": [
      {
        "translatedText": "....."
      }
    ]
  }
}

Is it possible to get all variations (alternatives) of that word, not only 1 translation?

like image 359
T.Todua Avatar asked Dec 14 '22 12:12

T.Todua


1 Answers

Microsoft Azure supports one. https://learn.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-dictionary-lookup .

For ex. https://api.cognitive.microsofttranslator.com/dictionary/lookup?api-version=3.0&from=en&to=es

[ {"Text":"hello"} ]

gives you a list of translations like this:

[
{
    "normalizedSource": "hello",
    "displaySource": "hello",
    "translations": [
        {
            "normalizedTarget": "diga",
            "displayTarget": "diga",
            "posTag": "OTHER",
            "confidence": 0.6909,
            "prefixWord": "",
            "backTranslations": [
                {
                    "normalizedText": "hello",
                    "displayText": "hello",
                    "numExamples": 1,
                    "frequencyCount": 38
                }
            ]
        },
        {
            "normalizedTarget": "dime",
            "displayTarget": "dime",
            "posTag": "OTHER",
            "confidence": 0.3091,
            "prefixWord": "",
            "backTranslations": [
                {
                    "normalizedText": "tell me",
                    "displayText": "tell me",
                    "numExamples": 1,
                    "frequencyCount": 5847
                },
                {
                    "normalizedText": "hello",
                    "displayText": "hello",
                    "numExamples": 0,
                    "frequencyCount": 17
                }
            ]
        }
    ]
}

]

You can see 2 different translations in this case.

like image 91
Nikolai Kulikov Avatar answered Jan 11 '23 01:01

Nikolai Kulikov