- 概述
- 文档处理合同
- 发行说明
- 关于文档处理合同
- Box 类
- IPersistedActivity 接口
- PrettyBoxConverter 类
- IClassifierActivity 接口
- IClassifierCapabilitiesProvider 接口
- 分类器文档类型类
- 分类器结果类
- 分类器代码活动类
- 分类器原生活动类
- 分类器异步代码活动类
- 分类器文档类型功能类
- ContentValidationData Class
- EvaluatedBusinessRulesForFieldValue Class
- EvaluatedBusinessRuleDetails Class
- 提取程序异步代码活动类
- 提取程序代码活动类
- 提取程序文档类型类
- 提取程序文档类型功能类
- 提取程序字段功能类
- 提取程序原生活动类
- 提取程序结果类
- FieldValue Class
- FieldValueResult Class
- ICapabilitiesProvider 接口
- IExtractorActivity 接口
- 提取程序有效负载类
- 文档操作优先级枚举
- 文档操作数据类
- 文档操作状态枚举
- 文档操作类型枚举
- 文档分类操作数据类
- 文档验证操作数据类
- 用户数据类
- 文档类
- 文档拆分结果类
- DomExtensions 类
- 页类
- 页面分区类
- 多边形类
- 多边形转换器类
- 元数据类
- 词组类
- 词类
- 处理源枚举
- 结果表格单元类
- 结果表值类
- 结果表列信息类
- 结果表类
- 旋转枚举
- Rule Class
- RuleResult Class
- RuleSet Class
- RuleSetResult Class
- 分区类型枚举
- 词组类型枚举
- IDocumentTextProjection 接口
- 分类结果类
- 提取结果类
- 结果文档类
- 结果文档范围类
- 结果数据点类
- 结果值类
- 结果内容引用类
- 结果值令牌类
- 结果派生字段类
- 结果数据源枚举
- 结果常量类
- 简单字段值类
- 表字段值类
- 文档组类
- 文档分类类
- 文档类型类
- 字段类
- 字段类型枚举
- FieldValueDetails Class
- 语言信息类
- 元数据输入类
- 文本类型枚举
- 类型字段类
- ITrackingActivity 接口
- ITrainableActivity 接口
- ITrainableClassifierActivity 接口
- ITrainableExtractorActivity 接口
- 可训练的分类器异步代码活动类
- 可训练的分类器代码活动类
- 可训练的分类器原生活动类
- 可训练的提取程序异步代码活动类
- 可训练的提取程序代码活动类
- 可训练的提取程序原生活动类
- 基本数据点类 - 预览
- 提取结果处理程序类 - 预览
- Document Understanding ML
- Document Understanding OCR 本地服务器
- Document Understanding
- 智能 OCR
- 发行说明
- 关于“智能 OCR”活动包
- 项目兼容性
- 加载分类
- 将文档数字化
- 分类文档作用域
- 基于关键词的分类器
- Document Understanding 项目分类器
- 智能关键词分类器
- 创建文档分类操作
- 创建文档验证工件
- 检索文档验证工件
- 等待文档分类操作然后继续
- 训练分类器范围
- 基于关键词的分类训练器
- 智能关键词分类训练器
- 数据提取作用域
- Document Understanding 项目提取程序
- Document Understanding 项目提取程序训练器
- 基于正则表达式的提取程序
- 表单提取程序
- 智能表单提取程序
- 文档脱敏
- 创建文档验证操作
- 等待文档验证操作然后继续
- 训练提取程序范围
- 导出提取结果
- 机器学习提取程序
- 机器学习提取程序训练器
- 机器学习分类器
- 机器学习分类训练器
- 生成分类器
- 生成式提取程序
- 配置身份验证
- 使用应用程序操作验证文档
- 手动验证数字化文档
- 使用智能表单提取程序提取基于锚点的数据
- 验证站点
- 生成式活动 - 良好实践
- 生成式提取程序 - 良好做法
- 生成式分类器 - 良好做法
- ML 服务
- OCR
- OCR 合同
- OmniPage
- PDF
- [未公开] Abbyy
- [未列出] Abbyy 嵌入式

Document Understanding 活动
使用智能表单提取程序提取基于锚点的数据
以下示例说明了如何从可能还包含手写文本的表单中提取数据。 以下用例场景说明了如何从采购订单中提取数据。
它提供了诸如“数字化文档” 、 “数据提取作用域”或“智能表单提取程序”之类的活动。您可以在UiPath.IntelligentOCR.Activities包中找到这些活动。
创建工作流
在创建以下工作流之前,需要安装以下包:
- UiPath.DocumentProcessing.Contracts.Activities
- UiPath.Intelligent OCR.Activities
- UiPath.OCR.Activities
- UiPath.OCR.Contracts
- UiPath.WebAPI.Activities
Steps:
-
打开 Studio ,创建一个新“流程”。
-
在“工作流设计器”中添加一个“序列”容器,将其命名为“序列 1” ,然后创建下表中显示的变量:
表格 1. 要创建的变量
变量类型 默认值 item字符串 不适用 classificationResultClassificationResult[] 不适用 outputFileName泛型值 不适用 -
在第一个“序列”容器之后,在“工作流设计器”中添加另一个“序列”容器,将其命名为“序列 2” ,然后创建下表中显示的变量:
表 2. 要创建的变量
变量类型 默认值 text字符串 不适用 taxonomyDocumentTaxonomy 不适用 dom文档 不适用 documentPath字符串 不适用 classificationResult2ClassificationResult[] 不适用 outputFileName2泛型值 不适用 -
Add a Message Box activity inside the sequence.
- 在“属性”面板中,从“按钮”下拉列表中选择“确定”选项。在“文本”字段中添加以下消息:“选择 PDF 文件”。
-
选中“排名最前”选项的复选框。这会将消息框置于前台。
-
在“消息框”活动之后添加“选择文件”活动。
- 在“属性”面板中,向“筛选器”字段添加以下文本:
Pdf files (*.pdf)|*.pdf - Add the
documentPathvariable in the SelectedFile field.
- 在“属性”面板中,向“筛选器”字段添加以下文本:
-
将“分配”活动拖动至“选择文件”活动后面。
- Add the
outputFileName2variable in the To field. - 在“值”字段添加表达式
".temp/" + Path.GetFileName(documentPath)。
- Add the
-
在“分配”活动之后添加“反序列化 JSON”活动。
- Add the expression
File.ReadAllText("DocumentProcessing axonomy.json")in the JSON String field. - In the Properties panel, select the UiPath.DocumentProcessing.Contracts.Taxonomy.DocumentTaxonomy option from the TypeArgument dropdown list.
- Add the
taxonomyvariable in the JsonObject field.
- Add the expression
-
在“反序列化 JSON”活动之后添加“数字化文档”活动。
- In the Properties panel, add the value
1in the DegreeOfParallelism field. - Add the
documentPathvariable in the DocumentPath field. - Add the
domvariable in the DocumentObjectModel field. - Add the
textvariable in the DocumentText field. - 在活动中添加UiPath™ 文档 OCR引擎。
- Add your API Key inside the ApiKey field.
- Add the
"https://du.uipath.com/ocr"expression in the Endpoint field.
- In the Properties panel, add the value
-
在“数字化文档”活动之后添加“写入文本文件”活动。
- Add the
JsonConvert.SerializeObject(dom)expression in the Text field. - Add the
outputFileName2 + ".dom.json"expression in the FileName field.
- Add the
-
在“写入文本文件”活动之后添加另一个“写入文本文件”活动。
- Add the
textvariable in the Text field. - Add the
outputFileName2 + ".text.txt"expression in the FileName field.
- Add the
-
在“工作流设计器”中拖动另一个“序列”容器 ,将其命名为“序列 3” ,然后创建下表中显示的变量:
表 3. 要创建的变量
变量类型 默认值 extractionResult提取结果 不适用 validatedResults提取结果 不适用 doubleValidatedResults提取结果 不适用 dataset数据集 不适用 iInt32 不适用 -
Add a Data Extraction Scope activity inside the Sequence3.
- In the Properties panel, add the
domvariable in the DocumentObjectModel field. - Add the
documentPathvariable in the DocumentPath field. - Add the
textvariable in the DocumentText field. - Add the
"All.Benchmarks.Invoice"expression in the DocumentTypeId field. - Add the
taxonomyvariable in the Taxonomy field. - Add the
extractionResultvariable in the ExtractionResults field.
- In the Properties panel, add the
-
Add an Intelligent Form Extractor activity inside the Data Extraction Scope activity.
- Add your API Key in the ApiKey field.
-
在“数据提取作用域”活动之后添加“写入文本文件”活动。
- Add the
JsonConvert.SerializeObject(extractionResult)expression in the Text field. - Add the
outputFileName2 + ".results.json"expression in the FileName field.
- Add the
-
在“写入文本文件”活动之后添加“显示验证站点”活动。
- Add the
extractionResultvariable in the AutomaticExtractionResults field. - Add the
domvariable in the DocumentObjectModel field. - Add the
documentPathvariable in the DocumentPath field. - Add the
textvariable in the DocumentText field. - Add the
taxonomyvariable in the Taxonomy field. - Add the
validatedResultsvariable in the ValidatedExtractionResults field.
- Add the
-
在“显示验证站点”活动后添加“写入文本文件”活动。
- Add the
JsonConvert.SerializeObject(validatedResults)expression in the Text field. - Add the
outputFileName2 + ".savedinVS.results.json"expression in the FileName field.
- Add the
-
在“写入文本文件”活动之后添加另一个“写入文本文件”活动。
- Add the
JsonConvert.SerializeObject(doubleValidatedResults)expression in the Text field. - Add the
outputFileName2 + ".doubleSavedinVS.results.json"expression in the FileName field.
- Add the
-
运行流程。 自动化流程应打开验证站点,提取数据并进行验证,并将其存储在“输出”文件夹中。
请访问以下链接,将该示例下载为ZIP格式的文件:示例。
定义分类
您已经创建了工作流,定义了所有变量并自定义了所有活动。现在是时候定义分类了。请访问加载分类,了解有关定义自己的分类的信息。
创建分类,以便能够从发票中提取信息。您应该专注于创建“发票”文档类型,其中包含下表中显示的字段:
表 4. 发票文档类型字段
| 字段类型 | |
|---|---|
| 发票编号 | Text |
| 小计 | Number |
| 销售税 | Number |
| 总计 | Number |
图 1. 包含前面提到的字段的已完成分类的概览

创建模板
现在可以为提取流程创建模板。请访问加载分类,了解如何创建模板。
对于本示例,使用以下值配置模板:
- 文档类型:发票。
- 模板名称: Invoice-example。
- 模板文档:选择目标文件。
- OCR 引擎:Microsoft OCR。
- 语言:英语。
- 配置文件: 扫描。
- 规模:1。
图 2. 显示模板配置的动图示例

在模板中设置锚点
当您需要从文档中提取精确信息时,锚点是一项非常特殊且有用的功能。 通过使用锚点定义提取区域,您可以期望数据提取具有较高的准确性。
定义分类并创建模板后,您可以使用锚点开始配置模板,这意味着在框中定义提取区域,并且使用锚点定义框位置。
在开始将锚点添加到模板之前,请查看以下列表,以获取一些建议:
- 锚框应尽可能大(高度、宽度),以覆盖任何类型的发票编号(长、短、大字体等)。
- 一个提取区域可以根据需要具有任意数量的锚点,但只能将一个锚点定义为主锚点(第一个)。
- 使用由多个并排单词组成的锚点。
- 主锚点应尽可能靠近提取区域。
- 提取区域和主锚点的位置在模板中是固定的,即使应用于不同的文档也是如此。 唯一可以改变的是主锚点和次要锚点之间的距离。
让我们继续配置模板,看看如何使用锚点提取数据。
- 设置提取区域:
-
在“验证站点”右侧的区域中,选择“选择模式” 。
-
选择“锚点” 。
-
开始选择所需的区域。
备注:主锚点应包含两个或三个单词,以便在提取过程中获得更高的准确性和更好的结果。
标记锚点时,通过按 CTRL 键并选择所需字词来选择多个字词。
-
- 设置主锚点:
- 当仍处于“锚点”选择模式时,选择所需的区域作为主锚点。
- 选择所需字段的“提取值” 。
- 设置次要锚点:
- 确保您仍处于“锚点”选择模式,并激活主锚点选择。
- 为次要锚点选择新区域。
- 为所需字段选择“选项” ,然后选择“更改提取的值” 。
重复此过程,直到完成所有提取区域的定义并添加所有锚点。 完成后,保存模板。