从 Google Translate API 获取多种变体

T.T*_*dua 3 google-translate google-cloud-platform google-translation-api

当我们查询 Translate API 时

https://translation.googleapis.com/language/translate/v2?key=$API_KEY&q=hello&source=en&target=e
Run Code Online (Sandbox Code Playgroud)

我只得到 1 个结果:

{
  "data": {
    "translations": [
      {
        "translatedText": "....."
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

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

Arm*_*_SC 7

翻译 API 服务不支持检索单词的多个翻译,如常见问题解答文档中所述:

是否有可能获得一个单词的多个翻译? 不可以。此功能只能通过网络界面使用: translate.google.com

如果此功能不能满足您当前的需求,您可以使用位于服务公共文档左下角和右上角的“发送反馈”按钮,以及查看“问题跟踪器”工具以提出问题翻译 API 功能请求并向 Google 通知此所需功能。

  • 常见问题解答目前不包含有关多种翻译的任何内容。 (5认同)

小智 7

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
                }
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

]

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