

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

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

要將亞馬遜 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`中，您可以指定人工檢工作流程 (流程定義)`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) 的開發套件*。

```
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"]'
```

------

**注意**  
 避免在 —human-loop config 參數中使用白色空格，因為這可能會導致代碼的處理問題。

對此請求的響應包含[人類循環活動產出](https://docs.aws.amazon.com/textract/latest/dg/API_HumanLoopActivationOutput.html)，它指示是否創建了人類循環，如果是，為什麼。如果創建了人類循環，則此對象還包含`HumanLoopArn`。

如需使用`AnalyzeDocument`操作，請參閲[使用 Amazon Textract 分析文檔文本](analyzing-document-text.md)。