【问题标题】:Using Microsoft Custom Translator Category ID in the Translate Text API在翻译文本 API 中使用 Microsoft 自定义翻译类别 ID
【发布时间】:2018-10-05 20:22:42
【问题描述】:

在培训翻译后,我从 Microsoft 自定义翻译获得了类别 ID。现在我不知道需要插入到我已经拥有的文本翻译 API 中的脚本。

此处粘贴的示例代码。我刚刚输入了如下所示的类别 ID,但是,不确定启用它的正确脚本是什么。

代码示例:

# Replace the SUBSCRIPTION_KEY string value with your valid subscription key.
`SUBSCRIPTION_KEY = 'xxxx' #Place your subscription key here
HOST = 'api.cognitive.microsofttranslator.com'
PATH = '/translate?api-version=3.0'
`
# Replace the CATEGORY string value with your valid ID that you obtain from the Microsoft Custom Translator
`CATEGORY = 'xxxx'` 

# Translation from to parameter
`PARAMS = "&from=en&to=de"`

【问题讨论】:

  • 分类是url上的参数。所以你的参数字符串应该是 '&from=en&to=de&category=xxxx

标签: microsoft-translator


【解决方案1】:

您可以将类别传递给PARAMS,如下所示:

PARAMS = "&from=en&to=de&category=" + CATEGORY

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-20
    相关资源
    最近更新 更多