文本翻译 API 3.0:BreakSentenceTranslator Text API 3.0: BreakSentence

标识文本段中的句子边界的位置。Identifies the positioning of sentence boundaries in a piece of text.

请求 URLRequest URL

POST 请求发送到:Send a POST request to:


请求参数Request parameters

查询字符串上传递的请求参数如下:Request parameters passed on the query string are:

查询参数Query parameter 说明Description
api-versionapi-version 必需的查询参数。Required query parameter.
客户端所请求的 API 的版本。Version of the API requested by the client. 值必须是 3.0Value must be 3.0.
语言language 可选查询参数。Optional query parameter.
语言标记,标识输入文本的语言。Language tag identifying the language of the input text. 如果未指定代码,则将应用自动语言检测。If a code is not specified, automatic language detection will be applied.
脚本script 可选查询参数。Optional query parameter.
脚本标记,标识输入文本使用的脚本。Script tag identifying the script used by the input text. 如果未指定脚本,则将采用语言的默认脚本。If a script is not specified, the default script of the language will be assumed.

请求标头包括:Request headers include:

标头Headers 说明Description
身份验证标头Authentication header(s) 必需的请求标头。Required request header.
请参阅用于身份验证的可用选项See available options for authentication.
Content-TypeContent-Type 必需的请求标头。Required request header.
指定有效负载的内容类型。Specifies the content type of the payload. 可能的值为:application/jsonPossible values are: application/json.
Content-LengthContent-Length 必需的请求标头。Required request header.
请求正文的长度。The length of the request body.
X-ClientTraceIdX-ClientTraceId 可选。Optional.
客户端生成的 GUID,用于唯一标识请求。A client-generated GUID to uniquely identify the request. 请注意,如果在查询字符串中使用名为 ClientTraceId 的查询参数包括了跟踪 ID,则可以省略此标头。Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId.

请求正文Request body

请求的正文是一个 JSON 数组。The body of the request is a JSON array. 每个数组元素都是一个 JSON 对象,具有名为 Text 的字符串属性。Each array element is a JSON object with a string property named Text. 句子边界是针对 Text 属性的值计算的。Sentence boundaries are computed for the value of the Text property. 具有一个文本段的示例请求正文如下所示:A sample request body with one piece of text looks like that:

    { "Text": "How are you? I am fine. What did you do today?" }

以下限制适用:The following limitations apply:

  • 数组最多可具有 100 个元素。The array can have at most 100 elements.
  • 数组元素的文本值不能超过 10,000 个字符(包括空格)。The text value of an array element cannot exceed 10,000 characters including spaces.
  • 包括空格在内,请求中包含的整个文本不能超过 50,000 个字符。The entire text included in the request cannot exceed 50,000 characters including spaces.
  • 如果指定了 language 查询参数,则所有数组元素必须采用同一语言。If the language query parameter is specified, then all array elements must be in the same language. 否则,将分别向每个数组元素应用语言自动检测。Otherwise, language auto-detection is applied to each array element independently.

响应正文Response body

成功的响应是一个 JSON 数组,其中的每个结果对应于输入数组中的一个字符串。A successful response is a JSON array with one result for each string in the input array. 结果对象包括以下属性:A result object includes the following properties:

  • sentLen:一组整数,表示文本元素中各个句子的长度。sentLen: An array of integers representing the lengths of the sentences in the text element. 数组的长度是句子的数量,而各个值是每个句子的长度。The length of the array is the number of sentences, and the values are the length of each sentence.

  • detectedLanguage:一个对象,它通过以下属性描述检测到的语言:detectedLanguage: An object describing the detected language through the following properties:

    • language:已检测语言的代码。language: Code of the detected language.

    • score:一个浮点值,表示结果的置信度。score: A float value indicating the confidence in the result. 分数介于 0 和 1 之间,较低的分数表示较低的置信度。The score is between zero and one and a low score indicates a low confidence.

    请注意,当请求了语言自动检测时,detectedLanguage 属性仅存在于结果对象中。Note that the detectedLanguage property is only present in the result object when language auto-detection is requested.

示例 JSON 响应如下:An example JSON response is:

    "sentenceLengths": [ 13, 11, 22 ]
    "detectedLanguage": {
      "language": "en",
      "score": 401

响应标头Response headers

标头Headers 说明Description
X-RequestIdX-RequestId 服务生成的用于标识请求的值。Value generated by the service to identify the request. 它用于故障排除目的。It is used for troubleshooting purposes.

响应状态代码Response status codes

下面是请求可能返回的 HTTP 状态代码。The following are the possible HTTP status codes that a request returns.

状态代码Status Code 说明Description
200200 成功。Success.
400400 查询参数之一缺失或无效。One of the query parameters is missing or not valid. 请更正请求参数,然后重试。Correct request parameters before retrying.
401401 无法对请求进行身份验证。The request could not be authenticated. 请确保凭据已指定且有效。Check that credentials are specified and valid.
403403 请求未经授权。The request is not authorized. 请检查详细错误消息。Check the details error message. 这通常表示试用订阅提供的所有可用翻译已用完。This often indicates that all free translations provided with a trial subscription have been used up.
429429 由于客户端已超出请求限制,服务器拒绝了请求。The server rejected the request because the client has exceeded request limits.
500500 发生了意外错误。An unexpected error occurred. 如果错误持续存在,请报告相关信息:发生故障的日期和时间、响应标头 X-RequestId 中的请求标识符、请求标头 X-ClientTraceId 中的客户端标识符。If the error persists, report it with: date and time of the failure, request identifier from response header X-RequestId, and client identifier from request header X-ClientTraceId.
503503 服务器暂不可用。Server temporarily unavailable. 重试请求。Retry the request. 如果错误持续存在,请报告相关信息:发生故障的日期和时间、响应标头 X-RequestId 中的请求标识符、请求标头 X-ClientTraceId 中的客户端标识符。If the error persists, report it with: date and time of the failure, request identifier from response header X-RequestId, and client identifier from request header X-ClientTraceId.

如果发生错误,请求也将返回 JSON 错误响应。If an error occurs, the request will also return a JSON error response. 错误代码是一个 6 位数字,包括 3 位数的 HTTP 状态代码,后接用于进一步将错误分类的 3 位数。The error code is a 6-digit number combining the 3-digit HTTP status code followed by a 3-digit number to further categorize the error. 常见错误代码可在 v3 文本翻译 API 参考页面上找到。Common error codes can be found on the v3 Translator Text API reference page.


下面的示例展示了如何获取单个句子的句子边界。The following example shows how to obtain sentence boundaries for a single sentence. 服务会自动检测句子的语言。The language of the sentence is automatically detected by the service.

curl -X POST "https://api.translator.azure.cn/breaksentence?api-version=3.0" -H "Ocp-Apim-Subscription-Key: <client-secret>" -H "Ocp-Apim-Subscription-Region: your-region" -H "Content-Type: application/json" -d "[{'Text':'How are you? I am fine. What did you do today?'}]"