【问题标题】:Get multiple variations from Google Translate API从 Google Translate API 获取多种变体
【发布时间】:2019-07-10 10:47:45
【问题描述】:

当我们对 Translate API 进行查询时

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

我只得到 1 个结果:

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

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

【问题讨论】:

    标签: google-cloud-platform google-translate google-translation-api


    【解决方案1】:

    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 种不同的翻译。

    【讨论】:

    • 微软在这方面做得很好,但我想补充一点,到目前为止,此功能支持的语言对列表非常少,所以我建议检查它是否涵盖您的首先需要
    【解决方案2】:

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

    是否有可能获得一个单词的多个翻译? 没有。此功能仅可通过 Web 界面使用,网址为 translate.google.com

    如果此功能不能满足您当前的需求,您可以使用位于service public documentation 左下角和右上角的发送反馈按钮,以及采取查看Issue Tracker 工具以raise a Translation API feature request 并向Google 通知此所需功能。

    【讨论】:

    • FAQ 目前不包含任何关于多个翻译的内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-07
    • 2017-03-27
    • 2018-06-17
    • 2018-02-27
    • 2023-04-02
    • 2014-07-28
    • 1970-01-01
    相关资源
    最近更新 更多