4

当我们查询 Translate API 时

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

我只得到 1 个结果:

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

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

4

2 回答 2

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
                }
            ]
        }
    ]
}

]

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

于 2019-12-08T09:59:10.673 回答
5

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

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

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

于 2019-02-18T17:47:42.077 回答