你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Translator - Dictionary Examples
提供示例,说明如何在上下文中使用字典中的术语。 此操作与 Dictionary lookup
结合使用。
POST {Endpoint}/Dictionary/Examples?api-version=3.0&from={from}&to={to}
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
Endpoint
|
path | True |
string |
支持的认知服务终结点 |
api-version
|
query | True |
string |
客户端所请求的 API 的版本。 值必须为 3.0。 |
from
|
query | True |
string |
指定输入文本的语言。 源语言必须是 |
to
|
query | True |
string |
指定输出文本的语言。 目标语言必须是 |
请求头
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
X-ClientTraceId |
string |
客户端生成的 GUID,用于唯一标识请求。 请注意,如果使用名为 ClientTraceId 的查询参数在查询字符串中包含跟踪 ID,则可以省略此标头。 |
请求正文
名称 | 类型 | 说明 |
---|---|---|
text |
请求正文请求的正文是一个 JSON 数组。 每个数组元素都是一个具有以下属性的 JSON 对象:
以下限制适用:
响应正文成功的响应是一个 JSON 数组,其中的每个结果对应于输入数组中的一个字符串。 结果对象包括以下属性:
响应标头X-RequestId - 服务生成的用于标识请求的值。 它用于故障排除目的。
注意 - 如果字典中没有示例,则响应为 200 (正常) 但 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功 |
|
Other Status Codes |
错误响应。 |
安全性
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
Ocp-Apim-Subscription-Region
Type:
apiKey
In:
header
示例
DictionaryExample success example
Sample Request
POST https://api.cognitive.microsofttranslator.com/Dictionary/Examples?api-version=3.0&from=en&to=es
[
{
"text": "bug",
"translation": "bicho"
}
]
Sample Response
[
{
"normalizedSource": "bug",
"normalizedTarget": "bicho",
"examples": [
{
"sourcePrefix": "You feel like a ",
"sourceTerm": "bug",
"sourceSuffix": ".",
"targetPrefix": "Te sientes como un ",
"targetTerm": "bicho",
"targetSuffix": "."
},
{
"sourcePrefix": "Not to mention your friend the ",
"sourceTerm": "bug",
"sourceSuffix": ".",
"targetPrefix": "Aparte de tu amigo, el ",
"targetTerm": "bicho",
"targetSuffix": "."
},
{
"sourcePrefix": "Get on the magic ",
"sourceTerm": "bug",
"sourceSuffix": ".",
"targetPrefix": "Suban al ",
"targetTerm": "bicho",
"targetSuffix": " mágico."
},
{
"sourcePrefix": "Because this ",
"sourceTerm": "bug",
"sourceSuffix": " is not an insect.",
"targetPrefix": "Porque este ",
"targetTerm": "bicho",
"targetSuffix": " no es un insecto."
},
{
"sourcePrefix": "I still taste that ",
"sourceTerm": "bug",
"sourceSuffix": ".",
"targetPrefix": "Aún tengo el sabor de ese ",
"targetTerm": "bicho",
"targetSuffix": "."
}
]
}
]
定义
名称 | 说明 |
---|---|
Dictionary |
成功的字典示例请求示例 |
Dictionary |
字典示例请求所需的文本 |
Error | |
Error |
|
Examples |
DictionaryExampleResult
成功的字典示例请求示例
名称 | 类型 | 说明 |
---|---|---|
examples |
Examples[] |
|
normalizedSource |
string |
|
normalizedTarget |
string |
DictionaryExampleTextInput
字典示例请求所需的文本
名称 | 类型 | 说明 |
---|---|---|
text |
string |
|
translation |
string |
Error
名称 | 类型 | 说明 |
---|---|---|
code |
string |
|
message |
string |
ErrorMessage
名称 | 类型 | 说明 |
---|---|---|
error |
Examples
名称 | 类型 | 说明 |
---|---|---|
sourcePrefix |
string |
|
sourceSuffix |
string |
|
sourceTerm |
string |
|
targetPrefix |
string |
|
targetSuffix |
string |
|
targetTerm |
string |