

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

# 目標情緒的非同步分析
<a name="using-api-targeted-sentiment"></a>

如需目標情緒的即時分析資訊，請參閱 [目標情緒的即時分析](using-api-sync.md#get-started-api-targeted-sentiment)。

Amazon Comprehend 提供下列 API 操作，以啟動和管理非同步目標情緒分析：
+  [StartTargetedSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartTargetedSentimentDetectionJob.html) – 啟動文件集合的非同步目標情緒偵測任務。
+  [ListTargetedSentimentDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListTargetedSentimentDetectionJobs.html) – 傳回您已提交的目標情緒偵測任務清單。
+  [DescribeTargetedSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeTargetedSentimentDetectionJob.html) – 取得與指定目標情緒偵測任務相關聯的屬性 （包括狀態）。
+  [StopTargetedSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StopTargetedSentimentDetectionJob.html) – 停止指定的進行中目標情緒任務。

**Topics**
+ [開始之前](#api-targeted-sentiment-before)
+ [使用 分析目標情緒 AWS CLI](#api-targeted-sentiment-cli)

## 開始之前
<a name="api-targeted-sentiment-before"></a>

開始之前，請確定您已：
+ **輸入和輸出儲存貯**體 - 識別您要用於輸入和輸出的 Amazon S3 儲存貯體。儲存貯體必須與您呼叫的 API 位於相同的區域。
+ **IAM 服務角色** - 您必須擁有具有存取輸入和輸出儲存貯體許可的 IAM 服務角色。如需詳細資訊，請參閱[非同步操作所需的角色型許可](security_iam_id-based-policy-examples.md#auth-role-permissions)。

## 使用 分析目標情緒 AWS CLI
<a name="api-targeted-sentiment-cli"></a>

下列範例示範搭配 使用 `StartTargetedSentimentDetectionJob`操作 AWS CLI。此範例指定輸入文字的語言。

此範例格式適用於 Unix、Linux 和 macOS。用於 Windows 時，請以插入號 (^) 取代每一行結尾處的 Unix 接續字元斜線 (\$1)。

```
aws comprehend start-targeted-sentiment-detection-job \
       --job-name "job name" \
       --language-code "en" \
       --cli-input-json file://path to JSON input file
```

針對 `cli-input-json` 參數，您提供包含請求資料的 JSON 檔案路徑，如下列範例所示。

```
{
    "InputDataConfig": {
        "S3Uri": "s3://input bucket/input path",
        "InputFormat": "ONE_DOC_PER_FILE"
    },
    "OutputDataConfig": {
        "S3Uri": "s3://output bucket/output path"
    },
    "DataAccessRoleArn": "arn:aws:iam::account ID:role/data access role"
}
```

如果啟動任務的請求成功，您將會收到下列回應：

```
{
    "JobStatus": "SUBMITTED",
    "JobArn": "job ARN"
    "JobId": "job ID"
}
```