文本翻译认知技能Text Translation cognitive skill

文本翻译技能对文本进行评估,并针对每个记录返回已翻译为指定目标语言的文本。The Text Translation skill evaluates text and, for each record, returns the text translated to the specified target language. 此技能使用认知服务中提供的文本翻译 API v3.0This skill uses the Translator Text API v3.0 available in Cognitive Services.

此功能适用于你预期自己的文档可能不会全部采用一种语言的情况,在这种情况下,你可能会在编制索引以方便搜索之前通过翻译将文本标准化为单一语言。This capability is useful if you expect that your documents may not all be in one language, in which case you can normalize the text to a single language before indexing for search by translating it. 这也适用于本地化用例,即,你可能需要将同一文本的副本以多种语言发布。It is also useful for localization use cases, where you may want to have copies of the same text available in multiple languages.

文本翻译 API v3.0 是一项非区域性认知服务,这意味着,我们不保证你的数据与 Azure 认知搜索或附加的认知服务资源位于同一区域。The Translator Text API v3.0 is a non-regional Cognitive Service, meaning that your data is not guaranteed to stay in the same region as your Azure Cognitive Search or attached Cognitive Services resource.

备注

通过增大处理频率、添加更多文档或添加更多 AI 算法来扩大范围时,需要附加可计费的认知服务资源As you expand scope by increasing the frequency of processing, adding more documents, or adding more AI algorithms, you will need to attach a billable Cognitive Services resource. 调用认知服务中的 API 以及在 Azure 认知搜索中的文档破解阶段提取图像时,会产生费用。Charges accrue when calling APIs in Cognitive Services, and for image extraction as part of the document-cracking stage in Azure Cognitive Search. 提取文档中的文本不会产生费用。There are no charges for text extraction from documents.

当你行使内置技能时,我们会按现有的认知服务预付费价格收费。Execution of built-in skills is charged at the existing Cognitive Services pay-in-advance price. 图像提取定价如 Azure 认知搜索定价页所述。Image extraction pricing is described on the Azure Cognitive Search pricing page.

@odata.type

Microsoft.Skills.Text.TranslationSkillMicrosoft.Skills.Text.TranslationSkill

数据限制Data limits

记录的最大大小应为 50,000 个字符,通过 String.Length 进行测量。The maximum size of a record should be 50,000 characters as measured by String.Length. 如果在将数据发送到文本翻译技能之前需要将其拆分,请考虑使用文本拆分技能If you need to break up your data before sending it to the text translation skill, consider using the Text Split skill.

技能参数Skill parameters

参数区分大小写。Parameters are case-sensitive.

输入Inputs 说明Description
defaultToLanguageCodedefaultToLanguageCode (必需)将文档翻译为未显式指定语言的文档时所需的语言代码。(Required) The language code to translate documents into for documents that don't specify the to language explicitly.
请参阅支持的语言的完整列表See Full list of supported languages.
defaultFromLanguageCodedefaultFromLanguageCode (可选)将文档从未显式指定语言的文档进行翻译时所需的语言代码。(Optional) The language code to translate documents from for documents that don't specify the from language explicitly. 如果未指定 defaultFromLanguageCode,则会使用文本翻译 API 提供的自动语言检测功能来确定源语言。If the defaultFromLanguageCode is not specified, the automatic language detection provided by the Translator Text API will be used to determine the from language.
请参阅支持的语言的完整列表See Full list of supported languages.
suggestedFromsuggestedFrom (可选)在 fromLanguageCode 输入和 defaultFromLanguageCode 参数均未提供且自动语言检测操作不成功情况下,将文档从源语言进行翻译所需的语言代码。(Optional) The language code to translate documents from when neither the fromLanguageCode input nor the defaultFromLanguageCode parameter are provided, and the automatic language detection is unsuccessful. 如果未指定 suggestedFrom 语言,则会将英语 (en) 用作 suggestedFrom 语言。If the suggestedFrom language is not specified, English (en) will be used as the suggestedFrom language.
请参阅支持的语言的完整列表See Full list of supported languages.

技能输入Skill inputs

输入名称Input name 说明Description
texttext 要翻译的文本。The text to be translated.
toLanguageCodetoLanguageCode 一个表示文本翻译目标语言的字符串。A string indicating the language the text should be translated to. 如果未指定此输入,则使用 defaultToLanguageCode 来翻译文本。If this input is not specified, the defaultToLanguageCode will be used to translate the text.
请参阅支持的语言的完整列表See Full list of supported languages
fromLanguageCodefromLanguageCode 一个表示文本的当前语言的字符串。A string indicating the current language of the text. 如果此参数未指定,则会使用 defaultFromLanguageCode(在未提供 defaultFromLanguageCode 的情况下,则会使用自动语言检测功能)来翻译文本。If this parameter is not specified, the defaultFromLanguageCode (or automatic language detection if the defaultFromLanguageCode is not provided) will be used to translate the text.
请参阅支持的语言的完整列表See Full list of supported languages

技能输出Skill outputs

输出名称Output name 说明Description
translatedTexttranslatedText 进行从 translatedFromLanguageCode 到 translatedToLanguageCode 的文本翻译时获得的字符串结果。The string result of the text translation from the translatedFromLanguageCode to the translatedToLanguageCode.
translatedToLanguageCodetranslatedToLanguageCode 一个表示文本翻译目标语言代码的字符串。A string indicating the language code the text was translated to. 适用于需要翻译为多种语言且需要能够跟踪哪些文本是哪种语言的情况。Useful if you are translating to multiple languages and want to be able to keep track of which text is which language.
translatedFromLanguageCodetranslatedFromLanguageCode 一个表示文本翻译源语言代码的字符串。A string indicating the language code the text was translated from. 适用于已选择启用自动语言检测选项的情况,因为这种情况下的输出会提供该检测的结果。Useful if you opted for the automatic language detection option as this output will give you the result of that detection.

示例定义Sample definition

 {
    "@odata.type": "#Microsoft.Skills.Text.TranslationSkill",
    "defaultToLanguageCode": "fr",
    "suggestedFrom": "en",
    "context": "/document",
    "inputs": [
      {
        "name": "text",
        "source": "/document/text"
      }
    ],
    "outputs": [
      {
        "name": "translatedText",
        "targetName": "translatedText"
      },
      {
        "name": "translatedFromLanguageCode",
        "targetName": "translatedFromLanguageCode"
      },
      {
        "name": "translatedToLanguageCode",
        "targetName": "translatedToLanguageCode"
      }
    ]
  }

示例输入Sample input

{
  "values": [
    {
      "recordId": "1",
      "data":
        {
          "text": "We hold these truths to be self-evident, that all men are created equal."
        }
    },
    {
      "recordId": "2",
      "data":
        {
          "text": "Estamos muy felices de estar con ustedes."
        }
    }
  ]
}

示例输出Sample output

{
  "values": [
    {
      "recordId": "1",
      "data":
        {
          "translatedText": "Nous tenons ces vérités pour évidentes, que tous les hommes sont créés égaux.",
          "translatedFromLanguageCode": "en",
          "translatedToLanguageCode": "fr"
        }
    },
    {
      "recordId": "2",
      "data":
        {
          "translatedText": "Nous sommes très heureux d'être avec vous.",
          "translatedFromLanguageCode": "es",
          "translatedToLanguageCode": "fr"
        }
    }
  ]
}

错误和警告Errors and warnings

如果为源语言或目标语言提供的语言代码不受支持,则会生成错误且文本不会进行翻译。If you provide an unsupported language code for either the from or the to language, an error is generated and text is not translated. 如果你的文本为空,则不会生成警告。If your text is empty, a warning will be produced. 如果文本大于 50,000 个字符,则只会翻译前 50,000 个字符,并会发出警告。If your text is larger than 50,000 characters, only the first 50,000 characters will be translated and a warning will be issued.

另请参阅See also