

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Menggunakan Amazon Comprehend API
<a name="using-the-api"></a>

Amazon Comprehend API mendukung operasi untuk melakukan analisis dan operasi real-time (sinkron) untuk memulai dan mengelola pekerjaan analisis asinkron.

Anda dapat menggunakan operator Amazon Comprehend API secara langsung, atau Anda dapat menggunakan CLI atau salah satunya. SDKs Contoh dalam chapter ini menggunakan CLI, Python SDK, dan Java SDK.

Untuk menjalankan contoh AWS CLI dan Python, Anda harus menginstal. AWS CLI Untuk informasi selengkapnya, lihat [Mengatur AWS Command Line Interface (AWS CLI)](setting-up.md#setup-awscli).

Untuk menjalankan contoh Java, Anda harus menginstal file AWS SDK untuk Java. Untuk petunjuk untuk menginstal SDK for Java, [lihat Mengatur AWS SDK](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/setup.html) for Java.

**Topics**
+ [Menggunakan Amazon Comprehend dengan SDK AWS](sdk-general-information-section.md)
+ [Analisis real-time menggunakan API](using-api-sync.md)
+ [Pekerjaan analisis asinkron menggunakan API](api-async.md)

# Menggunakan Amazon Comprehend dengan SDK AWS
<a name="sdk-general-information-section"></a>

AWS kit pengembangan perangkat lunak (SDKs) tersedia untuk banyak bahasa pemrograman populer. Setiap SDK menyediakan API, contoh kode, dan dokumentasi yang memudahkan developer untuk membangun aplikasi dalam bahasa pilihan mereka.


| Dokumentasi SDK | Contoh kode | 
| --- | --- | 
| [AWS SDK untuk C\$1\$1](https://docs.aws.amazon.com/sdk-for-cpp) | [AWS SDK untuk C\$1\$1 contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp) | 
| [AWS CLI](https://docs.aws.amazon.com/cli) | [AWS CLI contoh kode](https://docs.aws.amazon.com/code-library/latest/ug/cli_2_code_examples.html) | 
| [AWS SDK untuk Go](https://docs.aws.amazon.com/sdk-for-go) | [AWS SDK untuk Go contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2) | 
| [AWS SDK untuk Java](https://docs.aws.amazon.com/sdk-for-java) | [AWS SDK untuk Java contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2) | 
| [AWS SDK untuk JavaScript](https://docs.aws.amazon.com/sdk-for-javascript) | [AWS SDK untuk JavaScript contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3) | 
| [AWS SDK untuk Kotlin](https://docs.aws.amazon.com/sdk-for-kotlin) | [AWS SDK untuk Kotlin contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin) | 
| [AWS SDK untuk .NET](https://docs.aws.amazon.com/sdk-for-net) | [AWS SDK untuk .NET contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3) | 
| [AWS SDK untuk PHP](https://docs.aws.amazon.com/sdk-for-php) | [AWS SDK untuk PHP contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php) | 
| [Alat AWS untuk PowerShell](https://docs.aws.amazon.com/powershell) | [Alat AWS untuk PowerShell contoh kode](https://docs.aws.amazon.com/code-library/latest/ug/powershell_5_code_examples.html) | 
| [AWS SDK untuk Python (Boto3)](https://docs.aws.amazon.com/pythonsdk) | [AWS SDK untuk Python (Boto3) contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python) | 
| [AWS SDK untuk Ruby](https://docs.aws.amazon.com/sdk-for-ruby) | [AWS SDK untuk Ruby contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby) | 
| [AWS SDK for Rust](https://docs.aws.amazon.com/sdk-for-rust) | [AWS SDK for Rust contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1) | 
| [AWS SDK for SAP ABAP](https://docs.aws.amazon.com/sdk-for-sapabap) | [AWS SDK for SAP ABAP contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap) | 
| [AWS SDK for Swift](https://docs.aws.amazon.com/sdk-for-swift) | [AWS SDK for Swift contoh kode](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift) | 

**Ketersediaan contoh**  
Tidak dapat menemukan apa yang Anda butuhkan? Minta contoh kode menggunakan tautan **Berikan umpan balik** di bagian bawah halaman ini.

# Analisis real-time menggunakan API
<a name="using-api-sync"></a>

Contoh berikut menunjukkan cara menggunakan Amazon Comprehend API untuk analisis real-time, AWS CLI menggunakan, dan untuk .NET, Java, AWS SDKs dan Python. Gunakan contoh untuk mempelajari tentang operasi sinkron Amazon Comprehend dan sebagai blok bangunan untuk aplikasi Anda sendiri.

Contoh NET tersebut pada bagian ini menggunakan [AWS SDK untuk .NET](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html). Anda dapat menggunakan [AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/welcome.html)untuk mengembangkan AWS aplikasi menggunakan .NET. Ini termasuk template yang bermanfaat dan AWS Explorer untuk menyebarkan aplikasi dan mengelola layanan. Untuk perspektif pengembang.NET AWS, lihat [AWS panduan untuk pengembang.NET](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html). 

**Topics**
+ [Mendeteksi bahasa yang dominan](#get-started-api-dominant-language)
+ [Mendeteksi entitas bernama](#get-started-api-entities)
+ [Mendeteksi frase kunci](#get-started-api-key-phrases)
+ [Menentukan sentimen](#get-started-api-sentiment)
+ [Analisis real-time untuk sentimen yang ditargetkan](#get-started-api-targeted-sentiment)
+ [Mendeteksi sintaks](#get-started-api-syntax)
+ [Batch waktu nyata APIs](#get-started-batch)

## Mendeteksi bahasa yang dominan
<a name="get-started-api-dominant-language"></a>

Untuk menentukan bahasa dominan yang digunakan dalam teks, gunakan [DetectDominantLanguage](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectDominantLanguage.html)operasi. Untuk mendeteksi bahasa dominan hingga 25 dokumen dalam satu batch, gunakan [BatchDetectDominantLanguage](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectDominantLanguage.html)operasi. Untuk informasi selengkapnya, lihat [Batch waktu nyata APIs](#get-started-batch).

**Topics**
+ [Menggunakan AWS Command Line Interface](#get-started-api-dominant-language-cli)
+ [Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET](#get-started-api-dominant-language-java)

### Menggunakan AWS Command Line Interface
<a name="get-started-api-dominant-language-cli"></a>

Contoh berikut menunjukkan penggunaan `DetectDominantLanguage` operasi dengan. AWS CLI

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend detect-dominant-language \
    --region region \
    --text "It is raining today in Seattle."
```

Amazon Comprehend merespons dengan yang berikut:

```
{
    "Languages": [
        {
            "LanguageCode": "en",
            "Score": 0.9793661236763
        }
    ]
}
```

### Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET
<a name="get-started-api-dominant-language-java"></a>

Untuk contoh SDK tentang cara menentukan bahasa dominan, lihat[Gunakan `DetectDominantLanguage` dengan AWS SDK atau CLI](example_comprehend_DetectDominantLanguage_section.md).

## Mendeteksi entitas bernama
<a name="get-started-api-entities"></a>

Untuk menentukan entitas bernama dalam dokumen, gunakan [DetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectEntities.html)operasi. Untuk mendeteksi entitas hingga 25 dokumen dalam satu batch, gunakan [BatchDetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntities.html)operasi. Untuk informasi selengkapnya, lihat [Batch waktu nyata APIs](#get-started-batch).

**Topics**
+ [Menggunakan AWS Command Line Interface](#get-started-api-entities-cli)
+ [Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET](#get-started-api-entities-java)

### Menggunakan AWS Command Line Interface
<a name="get-started-api-entities-cli"></a>

Contoh berikut menunjukkan penggunaan `DetectEntities` operasi menggunakan. AWS CLI Anda harus menentukan bahasa teks input. 

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend detect-entities \
    --region region \
    --language-code "en" \
    --text "It is raining today in Seattle."
```

Amazon Comprehend merespons dengan yang berikut:

```
{
    "Entities": [
        {
            "Text": "today",
            "Score": 0.97,
            "Type": "DATE",
            "BeginOffset": 14,
            "EndOffset": 19
        },
        {
            "Text": "Seattle",
            "Score": 0.95,
            "Type": "LOCATION",
            "BeginOffset": 23,
            "EndOffset": 30
        }
    ],
    "LanguageCode": "en"
}
```

### Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET
<a name="get-started-api-entities-java"></a>

Untuk contoh SDK tentang cara menentukan bahasa dominan, lihat[Gunakan `DetectEntities` dengan AWS SDK atau CLI](example_comprehend_DetectEntities_section.md).

## Mendeteksi frase kunci
<a name="get-started-api-key-phrases"></a>

Untuk menentukan frasa kata benda kunci yang digunakan dalam teks, gunakan [DetectKeyPhrases](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectKeyPhrases.html)operasi. Untuk mendeteksi frasa kata benda kunci hingga 25 dokumen dalam satu batch, gunakan [BatchDetectKeyPhrases](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectKeyPhrases.html)operasi. Untuk informasi selengkapnya, lihat [Batch waktu nyata APIs](#get-started-batch).

**Topics**
+ [Menggunakan AWS Command Line Interface](#get-started-api-key-phrases-cli)
+ [Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET](#get-started-api-key-phrases-java)

### Menggunakan AWS Command Line Interface
<a name="get-started-api-key-phrases-cli"></a>

Contoh berikut menunjukkan penggunaan `DetectKeyPhrases` operasi dengan. AWS CLI Anda harus menentukan bahasa teks input.

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend detect-key-phrases \
    --region region \
    --language-code "en" \
    --text "It is raining today in Seattle."
```

Amazon Comprehend merespons dengan yang berikut:

```
{
    "LanguageCode": "en",
    "KeyPhrases": [
        {
            "Text": "today",
            "Score": 0.89,
            "BeginOffset": 14,
            "EndOffset": 19
        },
        {
            "Text": "Seattle",
            "Score": 0.91,
            "BeginOffset": 23,
            "EndOffset": 30
        }
    ]
}
```

### Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET
<a name="get-started-api-key-phrases-java"></a>

Untuk contoh SDK yang mendeteksi frasa kunci, lihat[Gunakan `DetectKeyPhrases` dengan AWS SDK atau CLI](example_comprehend_DetectKeyPhrases_section.md).

## Menentukan sentimen
<a name="get-started-api-sentiment"></a>

Amazon Comprehend menyediakan operasi API berikut untuk menganalisis sentimen:
+ [DetectSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectSentiment.html)— Menentukan sentimen emosional keseluruhan dari sebuah dokumen.
+  [BatchDetectSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectSentiment.html)— Tentukan sentimen keseluruhan hingga 25 dokumen dalam satu batch. Untuk informasi selengkapnya, lihat [Batch waktu nyata APIs](#get-started-batch)
+  [StartSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartSentimentDetectionJob.html)— Memulai pekerjaan deteksi sentimen asinkron untuk kumpulan dokumen.
+  [ListSentimentDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListSentimentDetectionJobs.html)— Mengembalikan daftar pekerjaan deteksi sentimen yang telah Anda kirimkan.
+  [DescribeSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeSentimentDetectionJob.html)— Mendapat properti (termasuk status) yang terkait dengan pekerjaan deteksi sentimen yang ditentukan.
+  [StopSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StopSentimentDetectionJob.html)— Menghentikan pekerjaan sentimen dalam proses yang ditentukan.

**Topics**
+ [Menggunakan AWS Command Line Interface](#get-started-api-sentiment-cli)
+ [Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET](#get-started-api-sentiment-java)

### Menggunakan AWS Command Line Interface
<a name="get-started-api-sentiment-cli"></a>

Contoh berikut menunjukkan penggunaan `DetectSentiment` operasi dengan. AWS CLI Contoh ini menentukan bahasa teks masukan.

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend detect-sentiment \
    --region region \
    --language-code "en" \
    --text "It is raining today in Seattle."
```

 Amazon Comprehend merespons dengan yang berikut:

```
{
    "SentimentScore": {
        "Mixed": 0.014585512690246105,
        "Positive": 0.31592071056365967,
        "Neutral": 0.5985543131828308,
        "Negative": 0.07093945890665054
    },
    "Sentiment": "NEUTRAL",
    "LanguageCode": "en"
}
```

### Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET
<a name="get-started-api-sentiment-java"></a>

Untuk contoh SDK yang menentukan sentimen teks masukan, lihat. [Gunakan `DetectSentiment` dengan AWS SDK atau CLI](example_comprehend_DetectSentiment_section.md)

## Analisis real-time untuk sentimen yang ditargetkan
<a name="get-started-api-targeted-sentiment"></a>

Amazon Comprehend menyediakan operasi API berikut untuk analisis sentimen real-time yang ditargetkan:
+ [DetectTargetedSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectTargetedSentiment.html)— Menganalisis sentimen entitas yang disebutkan dalam dokumen.
+  [BatchDetectTargetedSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectTargetedSentiment.html)— Menganalisis sentimen yang ditargetkan hingga 25 dokumen dalam satu batch. Untuk informasi selengkapnya, lihat [Batch waktu nyata APIs](#get-started-batch)

Jika teks yang Anda analisis tidak menyertakan sentimen yang ditargetkan[Jenis entitas](how-targeted-sentiment.md#how-targeted-sentiment-entities), API akan mengembalikan array Entitas kosong.

### Menggunakan AWS Command Line Interface
<a name="get-started-api-targeted-sentiment-cli"></a>

Contoh berikut menunjukkan penggunaan `DetectTargetedSentiment` operasi dengan. AWS CLI Contoh ini menentukan bahasa teks masukan.

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend detect-targeted-sentiment \
    --region region \
    --language-code "en" \
    --text "The burger was cooked perfectly but it was cold. The service was OK."
```

 Amazon Comprehend merespons dengan yang berikut:

```
{
"Entities": [
    {
      "DescriptiveMentionIndex": [
        0
      ],
      "Mentions": [
        {
          "BeginOffset": 4,
          "EndOffset": 10,
          "Score": 1,
          "GroupScore": 1,
          "Text": "burger",
          "Type": "OTHER",
          "MentionSentiment": {
            "Sentiment": "POSITIVE",
            "SentimentScore": {
              "Mixed": 0.001515,
              "Negative": 0.000822,
              "Neutral": 0.000243,
              "Positive": 0.99742
            }
          }
        },
        {
          "BeginOffset": 36,
          "EndOffset": 38,
          "Score": 0.999843,
          "GroupScore": 0.999661,
          "Text": "it",
          "Type": "OTHER",
          "MentionSentiment": {
            "Sentiment": "NEGATIVE",
            "SentimentScore": {
              "Mixed": 0,
              "Negative": 0.999996,
              "Neutral": 0.000004,
              "Positive": 0
            }
          }
        }
      ]
    },
    {
      "DescriptiveMentionIndex": [
        0
      ],
      "Mentions": [
        {
          "BeginOffset": 53,
          "EndOffset": 60,
          "Score": 1,
          "GroupScore": 1,
          "Text": "service",
          "Type": "ATTRIBUTE",
          "MentionSentiment": {
            "Sentiment": "NEUTRAL",
            "SentimentScore": {
              "Mixed": 0.000033,
              "Negative": 0.000089,
              "Neutral": 0.993325,
              "Positive": 0.006553
            }
          }
        }
      ]
    }
  ]
}
```

## Mendeteksi sintaks
<a name="get-started-api-syntax"></a>

Untuk mengurai teks untuk mengekstrak kata-kata individual dan menentukan bagian-bagian ucapan untuk setiap kata, gunakan [DetectSyntax](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectSyntax.html)operasi. Untuk mengurai sintaks hingga 25 dokumen dalam satu batch, gunakan operasi. [BatchDetectSyntax](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectSyntax.html) Untuk informasi selengkapnya, lihat [Batch waktu nyata APIs](#get-started-batch).

**Topics**
+ [Menggunakan AWS Command Line Interface.](#get-started-api-syntax-cli)
+ [Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET](#get-started-api-syntax-java)

### Menggunakan AWS Command Line Interface.
<a name="get-started-api-syntax-cli"></a>

Contoh berikut menunjukkan penggunaan `DetectSyntax` operasi dengan. AWS CLI Contoh ini menentukan bahasa teks masukan. 

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^). 

```
aws comprehend detect-syntax \
   --region region \
   --language-code "en" \
   --text "It is raining today in Seattle."
```

Amazon Comprehend merespons dengan yang berikut:

```
{
    "SyntaxTokens": [
        {
            "Text": "It",
            "EndOffset": 2,
            "BeginOffset": 0,
            "PartOfSpeech": {
                "Tag": "PRON",
                "Score": 0.8389829397201538
            },
            "TokenId": 1
        },
        {
            "Text": "is",
            "EndOffset": 5,
            "BeginOffset": 3,
            "PartOfSpeech": {
                "Tag": "AUX",
                "Score": 0.9189288020133972
            },
            "TokenId": 2
        },
        {
            "Text": "raining",
            "EndOffset": 13,
            "BeginOffset": 6,
            "PartOfSpeech": {
                "Tag": "VERB",
                "Score": 0.9977611303329468
            },
            "TokenId": 3
        },
        {
            "Text": "today",
            "EndOffset": 19,
            "BeginOffset": 14,
            "PartOfSpeech": {
                "Tag": "NOUN",
                "Score": 0.9993606209754944
            },
            "TokenId": 4
        },
        {
            "Text": "in",
            "EndOffset": 22,
            "BeginOffset": 20,
            "PartOfSpeech": {
                "Tag": "ADP",
                "Score": 0.9999061822891235
            },
            "TokenId": 5
        },
        {
            "Text": "Seattle",
            "EndOffset": 30,
            "BeginOffset": 23,
            "PartOfSpeech": {
                "Tag": "PROPN",
                "Score": 0.9940338730812073
            },
            "TokenId": 6
        },
        {
            "Text": ".",
            "EndOffset": 31,
            "BeginOffset": 30,
            "PartOfSpeech": {
                "Tag": "PUNCT",
                "Score": 0.9999997615814209
            },
            "TokenId": 7
        }
    ]
}
```

### Menggunakan AWS SDK untuk Java, SDK untuk Python, atau SDK untuk .NET
<a name="get-started-api-syntax-java"></a>

Untuk contoh SDK yang mendeteksi sintaks teks input, lihat. [Gunakan `DetectSyntax` dengan AWS SDK atau CLI](example_comprehend_DetectSyntax_section.md)

## Batch waktu nyata APIs
<a name="get-started-batch"></a>

Untuk mengirim batch hingga 25 dokumen, Anda dapat menggunakan operasi batch real-time Amazon Comprehend. Memanggil operasi batch identik dengan memanggil dokumen tunggal APIs untuk setiap dokumen dalam permintaan. Menggunakan batch APIs dapat menghasilkan kinerja yang lebih baik untuk aplikasi Anda. Untuk informasi selengkapnya, lihat [Beberapa dokumen pemrosesan sinkron](concepts-processing-modes.md#how-batch).

**Topics**
+ [Pemrosesan Batch dengan AWS CLI](#batch-cli)
+ [Pemrosesan Batch dengan AWS SDK untuk .NET](#batch-csharp)

### Pemrosesan Batch dengan AWS CLI
<a name="batch-cli"></a>

Contoh-contoh ini menunjukkan cara menggunakan operasi API batch menggunakan AWS Command Line Interface. Semua operasi kecuali `BatchDetectDominantLanguage` menggunakan file JSON berikut yang disebut `process.json` sebagai input. Untuk operasi itu `LanguageCode` entitas tidak termasuk.

Dokumen ketiga dalam file JSON (`"$$$$$$$$"`) akan menyebabkan kesalahan selama pemrosesan batch. Ini disertakan sehingga operasi akan termasuk [BatchItemError](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchItemError.html)dalam respons.

```
{
   "LanguageCode": "en",
   "TextList": [
      "I have been living in Seattle for almost 4 years",
      "It is raining today in Seattle",
      "$$$$$$$$"
   ]
}
```

Contohnya diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

**Topics**
+ [Mendeteksi bahasa dominan menggunakan batch (AWS CLI)](#batch-dominant-language)
+ [Mendeteksi entitas menggunakan batch (AWS CLI)](#batch-entities)
+ [Mendeteksi frase kunci menggunakan batch (AWS CLI)](#batch-key-phrase)
+ [Mendeteksi sentimen menggunakan batch ()AWS CLI](#batch-sentiment)

#### Mendeteksi bahasa dominan menggunakan batch (AWS CLI)
<a name="batch-dominant-language"></a>

[BatchDetectDominantLanguage](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectDominantLanguage.html)Operasi menentukan bahasa dominan dari setiap dokumen dalam satu batch. Untuk daftar bahasa yang Amazon Comprehend dapat mendeteksi, lihat. [Bahasa yang dominan](how-languages.md) AWS CLI Perintah berikut memanggil `BatchDetectDominantLanguage` operasi.

```
aws comprehend batch-detect-dominant-language \
    --endpoint endpoint \
    --region region \
    --cli-input-json file://path to input file/process.json
```

Berikut ini adalah respon dari `BatchDetectDominantLanguage` operasi:

```
{
    "ResultList": [
        {
          "Index": 0,
          "Languages":[
            {
              "LanguageCode":"en",
              "Score": 0.99
            }
          ]
        },
        {
          "Index": 1
          "Languages":[
            {
              "LanguageCode":"en",
              "Score": 0.82
            }
          ]
        }
    ],
    "ErrorList": [
      {
        "Index": 2,
        "ErrorCode": "InternalServerException",
        "ErrorMessage": "Unexpected Server Error. Please try again."
      }
    ]
}
```

#### Mendeteksi entitas menggunakan batch (AWS CLI)
<a name="batch-entities"></a>

Gunakan [BatchDetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntities.html)operasi untuk menemukan entitas yang ada dalam kumpulan dokumen. Untuk informasi selengkapnya tentang entitas, lihat[Entitas](how-entities.md). AWS CLI Perintah berikut memanggil `BatchDetectEntities` operasi.

```
aws comprehend batch-detect-entities \
    --endpoint endpoint \
    --region region \
    --cli-input-json file://path to input file/process.json
```

#### Mendeteksi frase kunci menggunakan batch (AWS CLI)
<a name="batch-key-phrase"></a>

[BatchDetectKeyPhrases](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectKeyPhrases.html)Operasi mengembalikan frase kata benda kunci dalam batch dokumen. AWS CLI Perintah berikut memanggil `BatchDetectKeyNounPhrases` operasi.

```
aws comprehend batch-detect-key-phrases
    --endpoint endpoint
    --region region
    --cli-input-json file://path to input file/process.json
```

#### Mendeteksi sentimen menggunakan batch ()AWS CLI
<a name="batch-sentiment"></a>

Mendeteksi sentimen keseluruhan dari sekumpulan dokumen menggunakan [BatchDetectSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectSentiment.html)operasi. AWS CLI Perintah berikut memanggil `BatchDetectSentiment` operasi.

```
aws comprehend batch-detect-sentiment \
    --endpoint endpoint \
    --region region \
    --cli-input-json file://path to input file/process.json
```

### Pemrosesan Batch dengan AWS SDK untuk .NET
<a name="batch-csharp"></a>

Contoh program berikut menunjukkan bagaimana menggunakan [BatchDetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntities.html)operasi dengan SDK untuk .NET. Respons dari server berisi [BatchDetectEntitiesItemResult](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntitiesItemResult.html)objek untuk setiap dokumen yang berhasil diproses. Jika ada kesalahan saat memproses dokumen, akan ada catatan dalam daftar kesalahan dalam respons. Contoh mendapatkan setiap dokumen dengan kesalahan dan mengirimkannya kembali.

Contoh .NET di bagian ini menggunakan [AWS SDK untuk .NET](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html). Anda dapat menggunakan [AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/welcome.html)untuk mengembangkan AWS aplikasi menggunakan .NET. Ini termasuk template yang bermanfaat dan AWS Explorer untuk menyebarkan aplikasi dan mengelola layanan. Untuk perspektif pengembang.NET AWS, lihat [AWS panduan untuk pengembang.NET](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html). 

```
using System;
using System.Collections.Generic;
using Amazon.Comprehend;
using Amazon.Comprehend.Model;

namespace Comprehend
{
    class Program
    {
        // Helper method for printing properties
        static private void PrintEntity(Entity entity)
        {
            Console.WriteLine("     Text: {0}, Type: {1}, Score: {2}, BeginOffset: {3} EndOffset: {4}",
                entity.Text, entity.Type, entity.Score, entity.BeginOffset, entity.EndOffset);
        }

        static void Main(string[] args)
        {
            AmazonComprehendClient comprehendClient = new AmazonComprehendClient(Amazon.RegionEndpoint.USWest2);

            List<String> textList = new List<String>()
            {
                { "I love Seattle" },
                { "Today is Sunday" },
                { "Tomorrow is Monday" },
                { "I love Seattle" }
            };

            // Call detectEntities API
            Console.WriteLine("Calling BatchDetectEntities");
            BatchDetectEntitiesRequest batchDetectEntitiesRequest = new BatchDetectEntitiesRequest()
            {
                TextList = textList,
                LanguageCode = "en"
            };
            BatchDetectEntitiesResponse batchDetectEntitiesResponse = comprehendClient.BatchDetectEntities(batchDetectEntitiesRequest);

            foreach (BatchDetectEntitiesItemResult item in batchDetectEntitiesResponse.ResultList)
            {
                Console.WriteLine("Entities in {0}:", textList[item.Index]);
                foreach (Entity entity in item.Entities)
                    PrintEntity(entity);
            }

            // check if we need to retry failed requests
            if (batchDetectEntitiesResponse.ErrorList.Count != 0)
            {
                Console.WriteLine("Retrying Failed Requests");
                List<String> textToRetry = new List<String>();
                foreach(BatchItemError errorItem in batchDetectEntitiesResponse.ErrorList)
                    textToRetry.Add(textList[errorItem.Index]);

                batchDetectEntitiesRequest = new BatchDetectEntitiesRequest()
                {
                    TextList = textToRetry,
                    LanguageCode = "en"
                };

                batchDetectEntitiesResponse = comprehendClient.BatchDetectEntities(batchDetectEntitiesRequest);

                foreach(BatchDetectEntitiesItemResult item in batchDetectEntitiesResponse.ResultList)
                {
                    Console.WriteLine("Entities in {0}:", textList[item.Index]);
                    foreach (Entity entity in item.Entities)
                        PrintEntity(entity);
                }
            }
            Console.WriteLine("End of DetectEntities");
        }
    }
}
```

# Pekerjaan analisis asinkron menggunakan API
<a name="api-async"></a>

Contoh berikut menggunakan Amazon APIs Comprehend asinkron untuk membuat dan mengelola pekerjaan analisis, menggunakan. AWS CLI

**Topics**
+ [Analisis asinkron untuk Amazon Comprehend wawasan](api-async-insights.md)
+ [Analisis asinkron untuk sentimen yang ditargetkan](using-api-targeted-sentiment.md)
+ [Analisis asinkron untuk deteksi peristiwa](get-started-api-events.md)
+ [Analisis asinkron untuk pemodelan topik](get-started-topics.md)

# Analisis asinkron untuk Amazon Comprehend wawasan
<a name="api-async-insights"></a>

Bagian berikut menggunakan Amazon Comprehend API untuk menjalankan operasi asinkron guna menganalisis wawasan Amazon Comprehend.

**Topics**
+ [Prasyarat](#detect-topics-role-auth)
+ [Memulai pekerjaan analisis](#how-start-job)
+ [Pekerjaan analisis pemantauan](#how-monitor-progress)
+ [Mendapatkan hasil analisis](#how-get-results)

## Prasyarat
<a name="detect-topics-role-auth"></a>

Dokumen harus dalam file teks berformat UTF-8. Anda dapat mengirimkan dokumen Anda dalam dua format. Format yang Anda gunakan tergantung pada jenis dokumen yang ingin Anda analisis, seperti yang dijelaskan dalam tabel berikut.


| Deskripsi | Format | 
| --- | --- | 
| Setiap file berisi satu dokumen masukan. Ini yang terbaik untuk koleksi dokumen besar. | Satu dokumen per file | 
|  Input adalah satu atau lebih file. Setiap baris dalam file dianggap sebagai dokumen. Ini terbaik untuk dokumen pendek, seperti posting media sosial. Setiap baris harus diakhiri dengan umpan baris (LF,\$1n), carriage return (CR,\$1 r), atau keduanya (CRLF,\$1 r\$1n). Anda tidak dapat menggunakan pemisah garis UTF-8 (u\$12028) untuk mengakhiri garis.  | Satu dokumen per baris | 

Saat Anda memulai pekerjaan analisis, Anda menentukan lokasi S3 untuk data input Anda. URI harus berada di AWS Wilayah yang sama dengan titik akhir API yang Anda panggil. URI dapat menunjuk ke satu file atau dapat menjadi awalan untuk kumpulan file data. Untuk informasi selengkapnya, lihat tipe data [InputDataConfig](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_InputDataConfig.html).

Anda harus memberikan Amazon Comprehend akses ke bucket Amazon S3 yang berisi koleksi dokumen dan file keluaran Anda. Untuk informasi selengkapnya, lihat [Izin berbasis peran yang diperlukan untuk operasi asinkron](security_iam_id-based-policy-examples.md#auth-role-permissions).

## Memulai pekerjaan analisis
<a name="how-start-job"></a>

Untuk mengirimkan pekerjaan analisis, gunakan konsol Amazon Comprehend atau operasi yang sesuai: `Start*`
+  [StartDominantLanguageDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartDominantLanguageDetectionJob.html)— Mulai pekerjaan untuk mendeteksi bahasa dominan di setiap dokumen dalam koleksi. Untuk informasi lebih lanjut tentang bahasa dominan dalam dokumen, lihat[Bahasa yang dominan](how-languages.md).
+  [StartEntitiesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartEntitiesDetectionJob.html)— Mulai pekerjaan untuk mendeteksi entitas di setiap dokumen dalam koleksi. Untuk informasi selengkapnya tentang entitas, lihat[Entitas](how-entities.md).
+  [StartKeyPhrasesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartKeyPhrasesDetectionJob.html)— Mulai pekerjaan untuk mendeteksi frasa kunci di setiap dokumen dalam koleksi. Untuk informasi selengkapnya tentang frasa kunci, lihat[Frasa kunci](how-key-phrases.md).
+  [StartPiiEntitiesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartPiiEntitiesDetectionJob.html)— Mulai pekerjaan untuk mendeteksi informasi identitas pribadi (PII) di setiap dokumen dalam koleksi. Untuk informasi lebih lanjut tentang PII, lihat[Mendeteksi entitas PII](how-key-phrases.md).
+  [StartSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartSentimentDetectionJob.html)— Mulai pekerjaan untuk mendeteksi sentimen di setiap dokumen dalam koleksi. Untuk informasi lebih lanjut tentang sentimen, lihat[Sentimen](how-sentiment.md).

## Pekerjaan analisis pemantauan
<a name="how-monitor-progress"></a>

`Start*`Operasi mengembalikan ID yang dapat Anda gunakan untuk memantau kemajuan pekerjaan. 

Untuk memantau kemajuan menggunakan API, Anda menggunakan salah satu dari dua operasi, tergantung pada apakah Anda ingin memantau kemajuan pekerjaan individu atau beberapa pekerjaan. 

Untuk memantau kemajuan pekerjaan analisis individu, gunakan `Describe*` operasi. Anda memberikan ID pekerjaan yang dikembalikan oleh `Start*` operasi. Respons dari `Describe*` operasi berisi `JobStatus` bidang dengan status pekerjaan.

Untuk memantau kemajuan beberapa pekerjaan analisis, gunakan `List*` operasi. `List*`operasi mengembalikan daftar pekerjaan yang Anda kirimkan ke Amazon Comprehend. Tanggapan mencakup `JobStatus` bidang untuk setiap pekerjaan yang memberi tahu Anda status pekerjaan.

Jika bidang status disetel ke `COMPLETED` atau`FAILED`, pemrosesan pekerjaan telah selesai.

Untuk mendapatkan status pekerjaan individu, gunakan `Describe*` operasi untuk analisis yang Anda lakukan.
+  [DescribeDominantLanguageDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeDominantLanguageDetectionJob.html)
+  [DescribeEntitiesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeEntitiesDetectionJob.html)
+  [DescribeKeyPhrasesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeKeyPhrasesDetectionJob.html)
+  [DescribePiiEntitiesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribePiiEntitiesDetectionJob.html)
+  [DescribeSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeSentimentDetectionJob.html)

Untuk mendapatkan status beberapa pekerjaan, gunakan `List*` operasi untuk analisis yang Anda lakukan.
+  [ListDominantLanguageDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListDominantLanguageDetectionJobs.html)
+  [ListEntitiesDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListEntitiesDetectionJobs.html)
+  [ListKeyPhrasesDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListKeyPhrasesDetectionJobs.html)
+  [ListPiiEntitiesDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListPiiEntitiesDetectionJobs.html)
+  [ListSentimentDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListSentimentDetectionJobs.html)

Untuk membatasi hasil pada pekerjaan yang sesuai dengan kriteria tertentu, gunakan parameter `List*` operasi. `Filter` Anda dapat memfilter nama pekerjaan, status pekerjaan, dan tanggal dan waktu pekerjaan itu diajukan. Untuk informasi selengkapnya, lihat `Filter` parameter untuk setiap `List*` operasi di referensi Amazon Comprehend API.

## Mendapatkan hasil analisis
<a name="how-get-results"></a>

Setelah pekerjaan analisis selesai, gunakan `Describe*` operasi untuk mendapatkan lokasi hasil. Jika status pekerjaan`COMPLETED`, respons menyertakan `OutputDataConfig` bidang yang berisi bidang dengan lokasi Amazon S3 dari file keluaran. File,`output.tar.gz`, adalah arsip terkompresi yang berisi hasil analisis.

Jika status pekerjaan adalah`FAILED`, responsnya berisi `Message` bidang yang menjelaskan alasan pekerjaan analisis tidak berhasil diselesaikan.

Untuk mendapatkan status pekerjaan individu, gunakan `Describe*` operasi yang sesuai:
+  [DescribeDominantLanguageDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeDominantLanguageDetectionJob.html)
+  [DescribeEntitiesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeEntitiesDetectionJob.html)
+  [DescribeKeyPhrasesDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeKeyPhrasesDetectionJob.html)
+  [DescribeSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeSentimentDetectionJob.html)

Hasilnya dikembalikan dalam satu file, dengan satu struktur JSON untuk setiap dokumen. Setiap file respons juga menyertakan pesan kesalahan untuk pekerjaan apa pun dengan bidang status yang disetel ke`FAILED`.

Masing-masing bagian berikut menunjukkan contoh output untuk dua format input.

### Mendapatkan hasil deteksi bahasa yang dominan
<a name="async-dominant-language"></a>

Berikut ini adalah contoh file output dari analisis yang mendeteksi bahasa dominan. Format input adalah satu dokumen per baris. Untuk informasi lebih lanjut, lihat [DetectDominantLanguage](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectDominantLanguage.html)operasi.

```
{"File": "0_doc", "Languages": [{"LanguageCode": "en", "Score": 0.9514502286911011}, {"LanguageCode": "de", "Score": 0.02374090999364853}, {"LanguageCode": "nl", "Score": 0.003208699868991971}, "Line": 0}
{"File": "1_doc", "Languages": [{"LanguageCode": "en", "Score": 0.9822712540626526}, {"LanguageCode": "de", "Score": 0.002621392020955682}, {"LanguageCode": "es", "Score": 0.002386554144322872}], "Line": 1}
```

Berikut ini adalah contoh output dari analisis di mana format input adalah satu dokumen per file:

```
{"File": "small_doc", "Languages": [{"LanguageCode": "en", "Score": 0.9728053212165833}, {"LanguageCode": "de", "Score": 0.007670710328966379}, {"LanguageCode": "es", "Score": 0.0028472368139773607}]}
{"File": "huge_doc", "Languages": [{"LanguageCode": "en", "Score": 0.984955906867981}, {"LanguageCode": "de", "Score": 0.0026436643674969673}, {"LanguageCode": "fr", "Score": 0.0014206881169229746}]}
```

### Mendapatkan hasil deteksi entitas
<a name="async-entities"></a>

Berikut ini adalah contoh file output dari analisis yang mendeteksi entitas dalam dokumen. Format input adalah satu dokumen per baris. Untuk informasi lebih lanjut, lihat [DetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectEntities.html)operasi. Output berisi dua pesan kesalahan, satu untuk dokumen yang terlalu panjang dan satu untuk dokumen yang tidak dalam format UTF-8.

```
{"File": "50_docs", "Line": 0, "Entities": [{"BeginOffset": 0, "EndOffset": 22, "Score": 0.9763959646224976, "Text": "Cluj-NapocaCluj-Napoca", "Type": "LOCATION"}"]}
{"File": "50_docs", "Line": 1, "Entities": [{"BeginOffset": 11, "EndOffset": 15, "Score": 0.9615424871444702, "Text": "Maat", "Type": "PERSON"}}]}
{"File": "50_docs", "Line": 2, "ErrorCode": "DOCUMENT_SIZE_EXCEEDED", "ErrorMessage": "Document size exceeds maximum size limit 102400 bytes."}
{"File": "50_docs", "Line": 3, "ErrorCode": "UNSUPPORTED_ENCODING", "ErrorMessage": "Document is not in UTF-8 format and all subsequent lines are ignored."}
```

Berikut ini adalah contoh output dari analisis di mana format input adalah satu dokumen per file. Output berisi dua pesan kesalahan, satu untuk dokumen yang terlalu panjang dan satu untuk dokumen yang tidak dalam format UTF-8. 

```
{"File": "non_utf8.txt", "ErrorCode": "UNSUPPORTED_ENCODING", "ErrorMessage": "Document is not in UTF-8 format and all subsequent line are ignored."}
{"File": "small_doc", "Entities": [{"BeginOffset": 0, "EndOffset": 4, "Score": 0.645766019821167, "Text": "Maat", "Type": "PERSON"}]}
{"File": "huge_doc", "ErrorCode": "DOCUMENT_SIZE_EXCEEDED", "ErrorMessage": "Document size exceeds size limit 102400 bytes."}
```

### Mendapatkan hasil deteksi frase kunci
<a name="async-key-phrases"></a>

Berikut ini adalah contoh file output dari analisis yang mendeteksi frasa kunci dalam dokumen. Format input adalah satu dokumen per baris. Untuk informasi lebih lanjut, lihat [DetectKeyPhrases](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectKeyPhrases.html)operasi.

```
{"File": "50_docs", "KeyPhrases": [{"BeginOffset": 0, "EndOffset": 22, "Score": 0.8948641419410706, "Text": "Cluj-NapocaCluj-Napoca"}, {"BeginOffset": 45, "EndOffset": 49, "Score": 0.9989854693412781, "Text": "Cluj"}], "Line": 0}            
```

Berikut ini adalah contoh output dari analisis di mana format input adalah satu dokumen per file.

```
{"File": "1_doc", "KeyPhrases": [{"BeginOffset": 0, "EndOffset": 22, "Score": 0.8948641419410706, "Text": "Cluj-NapocaCluj-Napoca"}, {"BeginOffset": 45, "EndOffset": 49, "Score": 0.9989854693412781, "Text": "Cluj"}]}            
```

### Mendapatkan hasil deteksi informasi identitas pribadi (PII)
<a name="async-pii"></a>

Berikut ini adalah contoh file output dari pekerjaan analisis yang mendeteksi entitas PII dalam dokumen. Format input adalah satu dokumen per baris. 

```
{"Entities":[{"Type":"NAME","BeginOffset":40,"EndOffset":69,"Score":0.999995},{"Type":"ADDRESS","BeginOffset":247,"EndOffset":253,"Score":0.998828},{"Type":"BANK_ACCOUNT_NUMBER","BeginOffset":406,"EndOffset":411,"Score":0.693283}],"File":"doc.txt","Line":0}
{"Entities":[{"Type":"SSN","BeginOffset":1114,"EndOffset":1124,"Score":0.999999},{"Type":"EMAIL","BeginOffset":3742,"EndOffset":3775,"Score":0.999993},{"Type":"PIN","BeginOffset":4098,"EndOffset":4102,"Score":0.999995}],"File":"doc.txt","Line":1}
```

Berikut ini adalah contoh output dari analisis di mana format input adalah satu dokumen per file.

```
{"Entities":[{"Type":"NAME","BeginOffset":40,"EndOffset":69,"Score":0.999995},{"Type":"ADDRESS","BeginOffset":247,"EndOffset":253,"Score":0.998828},{"Type":"BANK_ROUTING","BeginOffset":279,"EndOffset":289,"Score":0.999999}],"File":"doc.txt"}
```

### Mendapatkan hasil deteksi sentimen
<a name="async-sentiment"></a>

Berikut ini adalah contoh file output dari analisis yang mendeteksi sentimen yang dinyatakan dalam dokumen. Ini termasuk pesan kesalahan karena satu dokumen terlalu panjang. Format input adalah satu dokumen per baris. Untuk informasi lebih lanjut, lihat [DetectSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectSentiment.html)operasi.

```
{"File": "50_docs", "Line": 0, "Sentiment": "NEUTRAL", "SentimentScore": {"Mixed": 0.002734508365392685, "Negative": 0.008935936726629734, "Neutral": 0.9841893315315247, "Positive": 0.004140198230743408}}
{"File": "50_docs", "Line": 1, "ErrorCode": "DOCUMENT_SIZE_EXCEEDED", "ErrorMessage": "Document size is exceeded maximum size limit 5120 bytes."}
{"File": "50_docs", "Line": 2, "Sentiment": "NEUTRAL", "SentimentScore": {"Mixed": 0.0023119584657251835, "Negative": 0.0029857370536774397, "Neutral": 0.9866572022438049, "Positive": 0.008045154623687267}}
```

Berikut ini adalah contoh output dari analisis di mana format input adalah satu dokumen per file.

```
{"File": "small_doc", "Sentiment": "NEUTRAL", "SentimentScore": {"Mixed": 0.0023450672160834074, "Negative": 0.0009663937962614, "Neutral": 0.9795311689376831, "Positive": 0.017157377675175667}}
{"File": "huge_doc", "ErrorCode": "DOCUMENT_SIZE_EXCEEDED", "ErrorMessage": "Document size is exceeds the limit of 5120 bytes."}
```

# Analisis asinkron untuk sentimen yang ditargetkan
<a name="using-api-targeted-sentiment"></a>

Untuk informasi tentang analisis real-time untuk sentimen Target, lihat[Analisis real-time untuk sentimen yang ditargetkan](using-api-sync.md#get-started-api-targeted-sentiment).

Amazon Comprehend menyediakan operasi API berikut untuk memulai dan mengelola analisis sentimen bertarget asinkron:
+  [StartTargetedSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartTargetedSentimentDetectionJob.html)— Memulai pekerjaan deteksi sentimen bertarget asinkron untuk kumpulan dokumen.
+  [ListTargetedSentimentDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListTargetedSentimentDetectionJobs.html)— Mengembalikan daftar pekerjaan deteksi sentimen yang ditargetkan yang telah Anda kirimkan.
+  [DescribeTargetedSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeTargetedSentimentDetectionJob.html)— Mendapat properti (termasuk status) yang terkait dengan pekerjaan deteksi sentimen bertarget yang ditentukan.
+  [StopTargetedSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StopTargetedSentimentDetectionJob.html)— Menghentikan pekerjaan sentimen yang ditargetkan dalam proses yang ditentukan.

**Topics**
+ [Sebelum Anda mulai](#api-targeted-sentiment-before)
+ [Menganalisis sentimen yang ditargetkan menggunakan AWS CLI](#api-targeted-sentiment-cli)

## Sebelum Anda mulai
<a name="api-targeted-sentiment-before"></a>

Sebelum Anda mulai, pastikan Anda memiliki:
+ **Bucket input dan output —Identifikasi bucket** Amazon S3 yang ingin Anda gunakan untuk input dan output. Bucket harus berada di Wilayah yang sama dengan API yang Anda panggil.
+ **Peran layanan IAM** —Anda harus memiliki peran layanan IAM dengan izin untuk mengakses bucket input dan output Anda. Untuk informasi selengkapnya, lihat [Izin berbasis peran yang diperlukan untuk operasi asinkron](security_iam_id-based-policy-examples.md#auth-role-permissions).

## Menganalisis sentimen yang ditargetkan menggunakan AWS CLI
<a name="api-targeted-sentiment-cli"></a>

Contoh berikut menunjukkan penggunaan `StartTargetedSentimentDetectionJob` operasi dengan. AWS CLI Contoh ini menentukan bahasa teks masukan.

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

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

Untuk `cli-input-json` parameter Anda menyediakan path ke file JSON yang berisi data permintaan, seperti yang ditunjukkan pada contoh berikut.

```
{
    "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"
}
```

Jika permintaan untuk memulai pekerjaan berhasil, Anda akan menerima tanggapan berikut:

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

# Analisis asinkron untuk deteksi peristiwa
<a name="get-started-api-events"></a>

**Topics**
+ [Sebelum Anda mulai](#events-before)
+ [Mendeteksi peristiwa menggunakan AWS CLI](#events-cli)
+ [Daftar acara menggunakan AWS CLI](#list-events)
+ [Jelaskan peristiwa menggunakan AWS CLI](#describe-events)
+ [Dapatkan hasil deteksi peristiwa](#async-events)

Untuk mendeteksi peristiwa dalam kumpulan dokumen, gunakan [StartEventsDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartEventsDetectionJob.html)untuk memulai pekerjaan asinkron.

## Sebelum Anda mulai
<a name="events-before"></a>

Sebelum Anda mulai, pastikan Anda memiliki:
+ **Bucket input dan output —Identifikasi bucket** Amazon S3 yang ingin Anda gunakan untuk input dan output. Bucket harus berada di Wilayah yang sama dengan API yang Anda panggil.
+ **Peran layanan IAM** —Anda harus memiliki peran layanan IAM dengan izin untuk mengakses bucket input dan output Anda. Untuk informasi selengkapnya, lihat [Izin berbasis peran yang diperlukan untuk operasi asinkron](security_iam_id-based-policy-examples.md#auth-role-permissions).

## Mendeteksi peristiwa menggunakan AWS CLI
<a name="events-cli"></a>

Contoh berikut menunjukkan menggunakan [StartEventsDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartEventsDetectionJob.html)operasi dengan AWS CLI

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend start-events-detection-job \
  --region region \
  --job-name job name \
  --cli-input-json file://path to JSON input file
```

Untuk `cli-input-json` parameter Anda menyediakan path ke file JSON yang berisi data permintaan, seperti yang ditunjukkan pada contoh berikut.

```
{
  "InputDataConfig": {
      "S3Uri": "s3://input bucket/input path",
      "InputFormat": "ONE_DOC_PER_LINE"
  },
  "OutputDataConfig": {
      "S3Uri": "s3://output bucket/output path"
  },
  "DataAccessRoleArn": "arn:aws:iam::account ID:role/data access role"
  "LanguageCode": "en",
  "TargetEventTypes": [
      "BANKRUPTCY",
      "EMPLOYMENT",
      "CORPORATE_ACQUISITION",
      "INVESTMENT_GENERAL",
      "CORPORATE_MERGER",
      "IPO",
      "RIGHTS_ISSUE",
      "SECONDARY_OFFERING",
      "SHELF_OFFERING",
      "TENDER_OFFERING",
      "STOCK_SPLIT"
  ]
}
```

Jika permintaan untuk memulai pekerjaan deteksi peristiwa berhasil, Anda akan menerima tanggapan berikut:

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

## Daftar acara menggunakan AWS CLI
<a name="list-events"></a>

Gunakan [ListEventsDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListEventsDetectionJobs.html)operasi untuk melihat daftar pekerjaan deteksi peristiwa yang telah Anda kirimkan. Daftar ini mencakup informasi tentang lokasi input dan output yang Anda gunakan dan status setiap pekerjaan deteksi. Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend list-events-detection-jobs --region region 
```

Anda akan mendapatkan JSON yang mirip dengan yang berikut sebagai tanggapan:

```
{
 "EventsDetectionJobPropertiesList": [
    {
       "DataAccessRoleArn": "arn:aws:iam::account ID:role/data access role",
       "EndTime": timestamp,
       "InputDataConfig": {
          "InputFormat": "ONE_DOC_PER_LINE",
          "S3Uri": "s3://input bucket/input path"
       },
       "JobId": "job ID",
       "JobName": "job name",
       "JobStatus": "COMPLETED",
       "LanguageCode": "en",
       "Message": "message",
       "OutputDataConfig": {
          "S3Uri": "s3://output bucket/ouput path"
       },
       "SubmitTime": timestamp,
       "TargetEventTypes": [
         "BANKRUPTCY",
         "EMPLOYMENT",
         "CORPORATE_ACQUISITION",
         "INVESTMENT_GENERAL",
         "CORPORATE_MERGER",
         "IPO",
         "RIGHTS_ISSUE",
         "SECONDARY_OFFERING",
         "SHELF_OFFERING",
         "TENDER_OFFERING",
         "STOCK_SPLIT"
  ]
    }
 ],
 "NextToken": "next token"
}
```

## Jelaskan peristiwa menggunakan AWS CLI
<a name="describe-events"></a>

Anda dapat menggunakan [DescribeEventsDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeEventsDetectionJob.html)operasi untuk mendapatkan status pekerjaan yang ada. Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend describe-events-detection-job \
  --region region \
  --job-id job ID
```

Anda akan mendapatkan JSON berikut sebagai tanggapan:

```
{
 "EventsDetectionJobProperties": {
    "DataAccessRoleArn": "arn:aws:iam::account ID:role/data access role",
    "EndTime": timestamp,
    "InputDataConfig": {
       "InputFormat": "ONE_DOC_PER_LINE",
       "S3Uri": "S3Uri": "s3://input bucket/input path"
    },
    "JobId": "job ID",
    "JobName": "job name",
    "JobStatus": "job status",
    "LanguageCode": "en",
    "Message": "message",
    "OutputDataConfig": {
       "S3Uri": "s3://output bucket/output path"
    },
    "SubmitTime": timestamp,
    "TargetEventTypes": [
      "BANKRUPTCY",
      "EMPLOYMENT",
      "CORPORATE_ACQUISITION",
      "INVESTMENT_GENERAL",
      "CORPORATE_MERGER",
      "IPO",
      "RIGHTS_ISSUE",
      "SECONDARY_OFFERING",
      "SHELF_OFFERING",
      "TENDER_OFFERING",
      "STOCK_SPLIT"
  ]
 }
}
```

## Dapatkan hasil deteksi peristiwa
<a name="async-events"></a>

Berikut ini adalah contoh file output dari pekerjaan analisis yang mendeteksi peristiwa dalam dokumen. Format input adalah satu dokumen per baris. 

```
{"Entities": [{"Mentions": [{"BeginOffset": 12, "EndOffset": 27, "GroupScore": 1.0, "Score": 0.916355, "Text": "over a year ago", "Type": "DATE"}]}, {"Mentions": [{"BeginOffset": 33, "EndOffset": 39, "GroupScore": 1.0, "Score": 0.996603, "Text": "Amazon", "Type": "ORGANIZATION"}]}, {"Mentions": [{"BeginOffset": 66, "EndOffset": 77, "GroupScore": 1.0, "Score": 0.999283, "Text": "Whole Foods", "Type": "ORGANIZATION"}]}], "Events": [{"Arguments": [{"EntityIndex": 2, "Role": "INVESTEE", "Score": 0.999283}, {"EntityIndex": 0, "Role": "DATE", "Score": 0.916355}, {"EntityIndex": 1, "Role": "INVESTOR", "Score": 0.996603}], "Triggers": [{"BeginOffset": 373, "EndOffset": 380, "GroupScore": 0.999984, "Score": 0.999955, "Text": "acquire", "Type": "CORPORATE_ACQUISITION"}], "Type": "CORPORATE_ACQUISITION"}, {"Arguments": [{"EntityIndex": 2, "Role": "PARTICIPANT", "Score": 0.999283}], "Triggers": [{"BeginOffset": 115, "EndOffset": 123, "GroupScore": 1.0, "Score": 0.999967, "Text": "combined", "Type": "CORPORATE_MERGER"}], "Type": "CORPORATE_MERGER"}], "File": "doc.txt", "Line": 0}
```

Untuk informasi selengkapnya tentang struktur file keluaran peristiwa dan jenis acara yang didukung, lihat[Peristiwa](how-events.md).

# Analisis asinkron untuk pemodelan topik
<a name="get-started-topics"></a>

 Untuk menentukan topik dalam kumpulan dokumen, gunakan [StartTopicsDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartTopicsDetectionJob.html)untuk memulai pekerjaan asinkron. Anda dapat memantau topik dalam dokumen yang ditulis dalam bahasa Inggris atau Spanyol.

**Topics**
+ [Sebelum Anda mulai](#topics-before)
+ [Menggunakan AWS Command Line Interface](#topics-cli)
+ [Menggunakan SDK untuk Python atau SDK untuk .NET](#topic-java)

## Sebelum Anda mulai
<a name="topics-before"></a>

Sebelum Anda mulai, pastikan Anda memiliki:
+ **Bucket input dan output —Identifikasi bucket** Amazon S3 yang ingin Anda gunakan untuk input dan output. Bucket harus berada di Wilayah yang sama dengan API yang Anda panggil.
+ **Peran layanan IAM** —Anda harus memiliki peran layanan IAM dengan izin untuk mengakses bucket input dan output Anda. Untuk informasi selengkapnya, lihat [Izin berbasis peran yang diperlukan untuk operasi asinkron](security_iam_id-based-policy-examples.md#auth-role-permissions).

## Menggunakan AWS Command Line Interface
<a name="topics-cli"></a>

Contoh berikut menunjukkan menggunakan `StartTopicsDetectionJob` operasi dengan AWS CLI

Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend start-topics-detection-job \
                --number-of-topics topics to return \
                --job-name "job name" \
                --region region \
                --cli-input-json file://path to JSON input file
```

Untuk `cli-input-json` parameter Anda menyediakan path ke file JSON yang berisi data permintaan, seperti yang ditunjukkan pada contoh berikut.

```
{
    "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"
}
```

Jika permintaan untuk memulai pekerjaan deteksi topik berhasil, Anda akan menerima tanggapan berikut:

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

Gunakan [ListTopicsDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListTopicsDetectionJobs.html)operasi untuk melihat daftar pekerjaan deteksi topik yang telah Anda kirimkan. Daftar ini mencakup informasi tentang lokasi input dan output yang Anda gunakan dan status setiap pekerjaan deteksi. Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend list-topics-detection-jobs \-- region
```

Anda akan mendapatkan JSON yang mirip dengan yang berikut sebagai tanggapan:

```
{
    "TopicsDetectionJobPropertiesList": [
        {
            "InputDataConfig": {
                "S3Uri": "s3://input bucket/input path",
                "InputFormat": "ONE_DOC_PER_LINE"
            },
            "NumberOfTopics": topics to return,
            "JobId": "job ID",
            "JobStatus": "COMPLETED",
            "JobName": "job name",
            "SubmitTime": timestamp,
            "OutputDataConfig": {
                "S3Uri": "s3://output bucket/output path"
            },
            "EndTime": timestamp
        },
        {
            "InputDataConfig": {
                "S3Uri": "s3://input bucket/input path",
                "InputFormat": "ONE_DOC_PER_LINE"
            },
            "NumberOfTopics": topics to return,
            "JobId": "job ID",
            "JobStatus": "RUNNING",
            "JobName": "job name",
            "SubmitTime": timestamp,
            "OutputDataConfig": {
                "S3Uri": "s3://output bucket/output path"
            }
        }
    ]
}
```

Anda dapat menggunakan [DescribeTopicsDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeTopicsDetectionJob.html)operasi untuk mendapatkan status pekerjaan yang ada. Contoh diformat untuk Unix, Linux, dan macOS. Untuk Windows, ganti karakter kelanjutan backslash (\$1) Unix di akhir setiap baris dengan tanda sisipan (^).

```
aws comprehend describe-topics-detection-job --job-id job ID 
```

Anda akan mendapatkan JSON berikut sebagai tanggapan:

```
{
    "TopicsDetectionJobProperties": {
        "InputDataConfig": {
            "S3Uri": "s3://input bucket/input path",
            "InputFormat": "ONE_DOC_PER_LINE"
        },
        "NumberOfTopics": topics to return,
        "JobId": "job ID",
        "JobStatus": "COMPLETED",
        "JobName": "job name",
        "SubmitTime": timestamp,
        "OutputDataConfig": {
            "S3Uri": "s3://output bucket/ouput path"
        },
        "EndTime": timestamp
    }
}
```

## Menggunakan SDK untuk Python atau SDK untuk .NET
<a name="topic-java"></a>

Untuk contoh SDK tentang cara memulai pekerjaan pemodelan topik, lihat[Gunakan `StartTopicsDetectionJob` dengan AWS SDK atau CLI](example_comprehend_StartTopicsDetectionJob_section.md).