你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Document Models - Analyze Document

使用文档模型分析文档。

POST {endpoint}/formrecognizer/documentModels/{modelId}:analyze?api-version=2023-07-31
POST {endpoint}/formrecognizer/documentModels/{modelId}:analyze?pages={pages}&locale={locale}&stringIndexType={stringIndexType}&api-version=2023-07-31&features={features}

URI 参数

名称 必需 类型 说明
endpoint
path True

string

url

支持的认知服务终结点 (协议和主机名,例如: https://westus2.api.cognitive.microsoft.com) 。

modelId
path True

string

唯一的文档模型名称。

Regex pattern: ^[a-zA-Z0-9][a-zA-Z0-9._~-]{1,63}$

api-version
query True

string

请求的 API 版本。

features
query

DocumentAnalysisFeature[]

可选分析功能的列表。

locale
query

string

用于文本识别和文档分析的区域设置提示。 值只能包含语言代码(如“en”、“fr”)或 BCP 47 语言标记(如“en-US”)。

pages
query

string

要分析的从 1 开始的页码的列表。 例如: “1-3,5,7-9”

Regex pattern: ^(\d+(-\d+)?)(,\s*(\d+(-\d+)?))*$

stringIndexType
query

StringIndexType

用于计算字符串偏移量和长度的方法。

请求头

Media Types: "application/json", "application/octet-stream", "application/pdf", "image/jpeg", "image/png", "image/tiff", "image/bmp", "image/heif", "text/html", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.presentationml.presentation"

名称 必需 类型 说明
Ocp-Apim-Subscription-Key True

string

Azure 认知服务订阅的密钥。

请求正文

Media Types: "application/json", "application/octet-stream", "application/pdf", "image/jpeg", "image/png", "image/tiff", "image/bmp", "image/heif", "text/html", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.presentationml.presentation"

名称 类型 说明
base64Source

string

要分析的文档的 Base64 编码。 必须指定 urlSource 或 base64Source。

urlSource

string

要分析的文档 URL。 必须指定 urlSource 或 base64Source。

响应

名称 类型 说明
202 Accepted

请求已成功排队。

Headers

Operation-Location: string

Other Status Codes

ErrorResponse

遇到错误。

安全性

Ocp-Apim-Subscription-Key

Azure 认知服务订阅的密钥。

Type: apiKey
In: header

示例

Analyze Document from Base64
Analyze Document from Url

Analyze Document from Base64

Sample Request

POST https://myendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/prebuilt-layout:analyze?pages=1-2,4&locale=en-US&stringIndexType=textElements&api-version=2023-07-31

{
  "base64Source": "e2Jhc2U2NEVuY29kZWRQZGZ9"
}

Sample Response

Operation-Location: https://myendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/prebuilt-layout/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034?api-version=2023-07-31

Analyze Document from Url

Sample Request

POST https://myendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/customModel:analyze?pages=1-2,4&locale=en-US&stringIndexType=textElements&api-version=2023-07-31

{
  "urlSource": "http://host.com/doc.pdf"
}

Sample Response

Operation-Location: https://myendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/customModel/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034?api-version=2023-07-31

定义

名称 说明
AnalyzeDocumentRequest

文档分析参数。

DocumentAnalysisFeature

可选分析功能的列表。

Error

错误信息。

ErrorResponse

错误响应对象。

InnerError

详细错误。

StringIndexType

用于计算字符串偏移量和长度的方法。

AnalyzeDocumentRequest

文档分析参数。

名称 类型 说明
base64Source

string

要分析的文档的 Base64 编码。 必须指定 urlSource 或 base64Source。

urlSource

string

要分析的文档 URL。 必须指定 urlSource 或 base64Source。

DocumentAnalysisFeature

可选分析功能的列表。

名称 类型 说明
barcodes

string

启用文档中的条形码检测。

formulas

string

启用文档中数学表达式的检测。

keyValuePairs

string

启用对文档中) 窗体字段 (常规键值对的检测。

languages

string

启用文本内容语言检测。

ocrHighResolution

string

以更高的分辨率执行 OCR,以精细打印处理文档。

styleFont

string

启用各种字体样式的识别。

Error

错误信息。

名称 类型 说明
code

string

错误代码。

details

Error[]

详细错误列表。

innererror

InnerError

详细错误。

message

string

错误消息。

target

string

错误的目标。

ErrorResponse

错误响应对象。

名称 类型 说明
error

Error

错误信息。

InnerError

详细错误。

名称 类型 说明
code

string

错误代码。

innererror

InnerError

详细错误。

message

string

错误消息。

StringIndexType

用于计算字符串偏移量和长度的方法。

名称 类型 说明
textElements

string

Unicode 8.0.0 定义的用户感知显示字符或图形群集。

unicodeCodePoint

string

由单个 unicode 码位表示的字符单位。 由 Python 3 使用。

utf16CodeUnit

string

由 16 位 Unicode 代码单元表示的字符单元。 由 JavaScript、Java 和 .NET 使用。