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

Document Models - Analyze Document

使用文档模型分析文档。

POST {endpoint}/documentintelligence/documentModels/{modelId}:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview
POST {endpoint}/documentintelligence/documentModels/{modelId}:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview&pages={pages}&locale={locale}&stringIndexType={stringIndexType}&features={features}&queryFields={queryFields}&outputContentFormat={outputContentFormat}

URI 参数

名称 必需 类型 说明
endpoint
path True

string

文档智能服务终结点。

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”)。

outputContentFormat
query

ContentFormat

分析结果顶级内容的格式。

pages
query

string

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

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

queryFields
query

string[]

要提取的其他字段的列表。 例如: “NumberOfGuests,StoreNumber”

stringIndexType
query

StringIndexType

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

请求正文

名称 类型 说明
base64Source

string

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

urlSource

string

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

响应

名称 类型 说明
202 Accepted

已接受请求进行处理,但尚未完成处理。

Headers

  • Operation-Location: string
  • Retry-After: integer
Other Status Codes

ErrorResponse

意外的错误响应。

安全性

Ocp-Apim-Subscription-Key

Type: apiKey
In: header

OAuth2Auth

Type: oauth2
Flow: accessCode
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize
Token URL: https://login.microsoftonline.com/common/oauth2/token

Scopes

名称 说明
https://cognitiveservices.azure.com/.default

示例

Analyze Document from Base64
Analyze Document from Url

Analyze Document from Base64

Sample Request

POST https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-layout:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview&pages=1-2,4&locale=en-US&stringIndexType=textElements

{
  "base64Source": "e2Jhc2U2NEVuY29kZWRQZGZ9"
}

Sample Response

Operation-Location: https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-layout/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034?api-version=2024-02-29-preview

Analyze Document from Url

Sample Request

POST https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/customModel:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview&pages=1-2,4&locale=en-US&stringIndexType=textElements

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

Sample Response

Operation-Location: https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/customModel/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034?api-version=2024-02-29-preview

定义

名称 说明
AnalyzeDocumentRequest

文档分析参数。

ContentFormat

分析结果中的内容的格式。

DocumentAnalysisFeature

可选分析功能的列表。

Error

错误对象。

ErrorResponse

错误响应对象。

InnerError

包含有关错误的更具体信息的对象。

StringIndexType

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

AnalyzeDocumentRequest

文档分析参数。

名称 类型 说明
base64Source

string

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

urlSource

string

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

ContentFormat

分析结果中的内容的格式。

名称 类型 说明
markdown

string

包含节标题、表格等的文档内容的 Markdown 表示形式。

text

string

不带任何格式的文档内容的纯文本表示形式。

DocumentAnalysisFeature

可选分析功能的列表。

名称 类型 说明
barcodes

string

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

formulas

string

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

keyValuePairs

string

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

languages

string

启用文本内容语言的检测。

ocrHighResolution

string

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

queryFields

string

通过 queryFields 查询参数启用其他字段的提取。

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 使用。