从 Google 翻译 API 获取多种变体

Get multiple variations from Google Translate API

当我们查询翻译时 API

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

我只得到 1 个结果:

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

是否有可能获得该词的所有变体(替代词),而不仅仅是 1 个翻译?

翻译 API 服务不支持检索一个词的多个翻译,如 FAQ Documentation 中所述:

Is it possible to get multiple translations of a word? No. This feature is only available via the web interface at translate.google.com

如果此功能无法满足您当前的需求,您可以使用 发送反馈 按钮,该按钮位于 service public documentation, as well as take a look the Issue Tracker tool in order to raise a Translation API feature request 并通知 Google 有关此所需功能的信息。

Microsoft Azure 支持一个。 https://docs.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-dictionary-lookup .

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

[ {"Text":"hello"} ]

为您提供如下翻译列表:

[
{
    "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
                }
            ]
        }
    ]
}

]

在这种情况下,您可以看到 2 种不同的翻译。