

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 分析文档
<a name="a2i-textract-run-analyze-document"></a>

要将 Amazon A2I 融入到 Amazon Textract 文档分析工作流程中，您可以配置`HumanLoopConfig`中的[https://docs.aws.amazon.com/textract/latest/dg/API_AnalyzeDocument.html](https://docs.aws.amazon.com/textract/latest/dg/API_AnalyzeDocument.html)operation.

In`HumanLoopConfig`，您可以在中指定您的人工审核工作流（流定义）ARN`FlowDefinitionArn`，然后给你的人类循环一个名字`HumanLoopName`.

------
#### [  Analyze the Document (AWS SDK for Python (Boto3)) ]

以下示例使用 SDK for Python (Boto3) 调用`analyze_document`在 us-west-2 中。替换{{红色，斜体}}用你的资源发短信。有关更多信息，请参阅 。[分析 \_文档](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/textract.html#Textract.Client.analyze_document)中的*AWS适用于 Python 的开发工具包 (Boto) API 参考*.

```
client.analyze_document(Document={'S3Object': {"Bucket": "DOC-EXAMPLE-BUCKET", "Name": "document-name.png"}},
         HumanLoopConfig={"FlowDefinitionArn":"arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name",
                          "HumanLoopName":"human-loop-name",
                          "DataAttributes":{"ContentClassifiers":["FreeOfPersonallyIdentifiableInformation"|"FreeOfAdultContent",]}},
         FeatureTypes=["FORMS"])
```

------
#### [  Analyze the Document (AWS CLI) ]

以下示例使用AWS要打电话的 CLI`analyze_document`. 这些示例与AWSCLI 版本 2。第一个是速记语法，第二个是 JSON 语法。有关更多信息，请参阅 。[分析文档](https://docs.aws.amazon.com/cli/latest/reference/textract/analyze-document.html)中的*[AWS CLI命令参考](https://docs.aws.amazon.com/cli/latest/reference/)*.

```
aws textract analyze-document \
     --document '{"S3Object":{"Bucket":"{{bucket_name}}","Name":"{{file_name}}"}}' \
     --human-loop-config HumanLoopName="test",FlowDefinitionArn="arn:aws:sagemaker:eu-west-1:xyz:flow-definition/hl_name",DataAttributes='{ContentClassifiers=["FreeOfPersonallyIdentifiableInformation","FreeOfAdultContent"]}'\
     --feature-types '["FORMS"]'
```

```
aws textract analyze-document \
     --document '{"S3Object":{"Bucket":"{{bucket_name}}","Name":"{{file_name}}"}}' \
     --human-loop-config \
          '{"HumanLoopName":"test","FlowDefinitionArn":"arn:aws:sagemaker:eu-west-1:xyz:flow-definition/hl_name","DataAttributes": {"ContentClassifiers":["FreeOfPersonallyIdentifiableInformation","FreeOfAdultContent"]}}' \
     --feature-types '["FORMS"]'
```

------

**注意**  
 避免在 —人循环配置参数中使用白色空格，因为这可能会导致代码的处理问题。

对此请求的回复包括[HumanLoop 激活输出](https://docs.aws.amazon.com/textract/latest/dg/API_HumanLoopActivationOutput.html)，它表明是否创建了人类循环，如果是的话，为什么。如果创建了人类循环，则此对象还包含`HumanLoopArn`.

有关和示例的更多信息，请参阅`AnalyzeDocument`操作，请参阅[使用 Amazon Textract 分析文档文本](analyzing-document-text.md).