

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

# 使用 API 进行实时分析
<a name="using-api-sync"></a>

以下示例演示如何使用适用于.NET、Java 和 Python 的、 AWS SDKs 和 Amazon Com AWS CLI prehend API 进行实时分析。通过示例了解 Amazon Comprehend 同步操作，并将其作为您自己的应用程序的构建块。

本节中的 .NET 示例使用 [适用于 .NET 的 AWS SDK](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html)。您可以使用[AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/welcome.html)来开发使用.NET 的 AWS 应用程序。它包括用于部署应用程序和管理服务的有用模板和 AWS 资源管理器。有关.NET 开发人员的观点 AWS，[请参阅.NET 开发人员AWS 指南](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html)。

**Topics**
+ [检测占主要语言](#get-started-api-dominant-language)
+ [检测命名实体](#get-started-api-entities)
+ [检测关键短语](#get-started-api-key-phrases)
+ [确定情绪](#get-started-api-sentiment)
+ [目标情绪的实时分析](#get-started-api-targeted-sentiment)
+ [检测语法](#get-started-api-syntax)
+ [实时批处理 APIs](#get-started-batch)

## 检测占主要语言
<a name="get-started-api-dominant-language"></a>

要确定文本中使用的主导语言，请使用[DetectDominantLanguage](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectDominantLanguage.html)操作。要批量检测多达 25 个文档中的主要语言，请使用该[BatchDetectDominantLanguage](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectDominantLanguage.html)操作。有关更多信息，请参阅 [实时批处理 APIs](#get-started-batch)。

**Topics**
+ [使用 AWS Command Line Interface](#get-started-api-dominant-language-cli)
+ [使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK](#get-started-api-dominant-language-java)

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

以下示例演示了如何在 AWS CLI中使用 `DetectDominantLanguage` 操作。

此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

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

Amazon Comprehend 的响应如下：

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

### 使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK
<a name="get-started-api-dominant-language-java"></a>

有关如何确定主要语言的 SDK 示例，请参阅 [`DetectDominantLanguage`与 AWS SDK 或 CLI 配合使用](example_comprehend_DetectDominantLanguage_section.md)。

## 检测命名实体
<a name="get-started-api-entities"></a>

要确定文档中的命名实体，请使用[DetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectEntities.html)操作。要批量检测最多 25 个文档中的实体，请使用[BatchDetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntities.html)操作。有关更多信息，请参阅 [实时批处理 APIs](#get-started-batch)。

**Topics**
+ [使用 AWS Command Line Interface](#get-started-api-entities-cli)
+ [使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK](#get-started-api-entities-java)

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

以下示例演示了如何在 AWS CLI中使用 `DetectEntities` 操作。您必须指定输入文本的语言。

此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

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

Amazon Comprehend 的响应如下：

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

### 使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK
<a name="get-started-api-entities-java"></a>

有关如何确定主要语言的 SDK 示例，请参阅 [`DetectEntities`与 AWS SDK 或 CLI 配合使用](example_comprehend_DetectEntities_section.md)。

## 检测关键短语
<a name="get-started-api-key-phrases"></a>

要确定文本中使用的关键名词短语，请使用[DetectKeyPhrases](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectKeyPhrases.html)操作。要批量检测多达 25 个文档中的关键名词短语，请使用该[BatchDetectKeyPhrases](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectKeyPhrases.html)操作。有关更多信息，请参阅 [实时批处理 APIs](#get-started-batch)。

**Topics**
+ [使用 AWS Command Line Interface](#get-started-api-key-phrases-cli)
+ [使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK](#get-started-api-key-phrases-java)

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

以下示例演示了如何在 AWS CLI中使用 `DetectKeyPhrases` 操作。您必须指定输入文本的语言。

此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

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

Amazon Comprehend 的响应如下：

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

### 使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK
<a name="get-started-api-key-phrases-java"></a>

有关检测关键短语的 SDK 示例，请参阅 [`DetectKeyPhrases`与 AWS SDK 或 CLI 配合使用](example_comprehend_DetectKeyPhrases_section.md)。

## 确定情绪
<a name="get-started-api-sentiment"></a>

Amazon Comprehend 提供以下 API 操作，以便分析情绪：
+ [DetectSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectSentiment.html)— 确定文档的整体情感情绪。
+  [BatchDetectSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectSentiment.html)— 在一批中确定最多 25 个文档的总体情绪。有关更多信息，请参阅 [实时批处理 APIs](#get-started-batch)。
+  [StartSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StartSentimentDetectionJob.html)— 为一组文档启动异步情绪检测作业。
+  [ListSentimentDetectionJobs](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_ListSentimentDetectionJobs.html)— 返回您已提交的情绪检测任务列表。
+  [DescribeSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DescribeSentimentDetectionJob.html)— 获取与指定情绪检测作业关联的属性（包括状态）。
+  [StopSentimentDetectionJob](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_StopSentimentDetectionJob.html)— 停止指定的正在进行的情绪作业。

**Topics**
+ [使用 AWS Command Line Interface](#get-started-api-sentiment-cli)
+ [使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK](#get-started-api-sentiment-java)

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

以下示例演示了如何在 AWS CLI中使用 `DetectSentiment` 操作。此示例指定了输入文本的语言。

此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

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

 Amazon Comprehend 的响应如下：

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

### 使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK
<a name="get-started-api-sentiment-java"></a>

有关确定输入文本情绪的 SDK 示例，请参阅 [`DetectSentiment`与 AWS SDK 或 CLI 配合使用](example_comprehend_DetectSentiment_section.md)。

## 目标情绪的实时分析
<a name="get-started-api-targeted-sentiment"></a>

Amazon Comprehend 提供以下 API 操作，用于目标情绪的实时分析：
+ [DetectTargetedSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectTargetedSentiment.html)— 分析文档中提及的实体的情绪。
+  [BatchDetectTargetedSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectTargetedSentiment.html)— 批量分析最多 25 个文档的目标情绪。有关更多信息，请参阅 [实时批处理 APIs](#get-started-batch)。

如果您正在分析的文本不包含任何目标情绪 [实体类型](how-targeted-sentiment.md#how-targeted-sentiment-entities)，则 API 将返回一个空的实体数组。

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

以下示例演示了如何在 AWS CLI中使用 `DetectTargetedSentiment` 操作。此示例指定了输入文本的语言。

此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

```
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 的响应如下：

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

## 检测语法
<a name="get-started-api-syntax"></a>

要解析文本以提取单个单词并确定每个单词的语音部分，请使用[DetectSyntax](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectSyntax.html)操作。要批量解析最多 25 个文档的语法，请使用[BatchDetectSyntax](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectSyntax.html)操作。有关更多信息，请参阅 [实时批处理 APIs](#get-started-batch)。

**Topics**
+ [使用 AWS Command Line Interface.](#get-started-api-syntax-cli)
+ [使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK](#get-started-api-syntax-java)

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

以下示例演示了如何在 AWS CLI中使用 `DetectSyntax` 操作。此示例指定了输入文本的语言。

此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

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

Amazon Comprehend 的响应如下：

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

### 使用适用于 Python 的软件开发工具包，或 适用于 Java 的 AWS SDK 适用于 .NET 的 SDK
<a name="get-started-api-syntax-java"></a>

有关检测输入文本语法的 SDK 示例，请参阅 [`DetectSyntax`与 AWS SDK 或 CLI 配合使用](example_comprehend_DetectSyntax_section.md)。

## 实时批处理 APIs
<a name="get-started-batch"></a>

要发送最多 25 个文档的批，您可以使用 Amazon Comprehend 实时批处理操作。调用批处理操作与 APIs 为请求中的每个文档调用单个文档相同。使用批处理 APIs 可以提高应用程序的性能。有关更多信息，请参阅 [多文档同步处理](concepts-processing-modes.md#how-batch)。

**Topics**
+ [使用 Batch 处理 AWS CLI](#batch-cli)
+ [使用 Batch 处理 适用于 .NET 的 AWS SDK](#batch-csharp)

### 使用 Batch 处理 AWS CLI
<a name="batch-cli"></a>

这些示例显示如何通过 AWS Command Line Interface使用批处理 API 操作。除 `BatchDetectDominantLanguage` 之外的所有操作都使用以下名为 `process.json` JSON 文件作为输入。对于该操作，`LanguageCode` 实体不包括在内。

JSON 文件中的第三个文档 (`"$$$$$$$$"`) 会导致批处理时出错。它包含在内是为了使操作在响应[BatchItemError](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchItemError.html)中包含一个。

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

此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

**Topics**
+ [使用批处理 (AWS CLI) 检测主要语言](#batch-dominant-language)
+ [使用批处理 (AWS CLI) 检测实体](#batch-entities)
+ [使用批处理 (AWS CLI) 检测关键短语](#batch-key-phrase)
+ [使用批处理 (AWS CLI) 检测情绪](#batch-sentiment)

#### 使用批处理 (AWS CLI) 检测主要语言
<a name="batch-dominant-language"></a>

该[BatchDetectDominantLanguage](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectDominantLanguage.html)操作决定了批次中每个文档的主要语言。有关 Amazon Comprehend 可以检测的语言列表，请参阅 [主要语言](how-languages.md)。以下 AWS CLI 命令调用该`BatchDetectDominantLanguage`操作。

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

以下示例是 `BatchDetectDominantLanguage` 操作的响应：

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

#### 使用批处理 (AWS CLI) 检测实体
<a name="batch-entities"></a>

使用该[BatchDetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntities.html)操作查找一批文档中存在的实体。有关实体的更多信息，请参阅 [实体](how-entities.md)。以下 AWS CLI 命令调用了 `BatchDetectEntities` 操作。

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

#### 使用批处理 (AWS CLI) 检测关键短语
<a name="batch-key-phrase"></a>

该[BatchDetectKeyPhrases](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectKeyPhrases.html)操作返回一批文档中的关键名词短语。以下 AWS CLI 命令调用该`BatchDetectKeyNounPhrases`操作。

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

#### 使用批处理 (AWS CLI) 检测情绪
<a name="batch-sentiment"></a>

使用该[BatchDetectSentiment](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectSentiment.html)操作检测一批文档的整体情绪。以下 AWS CLI 命令调用该`BatchDetectSentiment`操作。

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

### 使用 Batch 处理 适用于 .NET 的 AWS SDK
<a name="batch-csharp"></a>

以下示例程序显示了如何将该[BatchDetectEntities](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntities.html)操作与一起使用 适用于 .NET 的 SDK。来自服务器的响应包含成功处理的每个文档的[BatchDetectEntitiesItemResult](https://docs.aws.amazon.com/comprehend/latest/APIReference/API_BatchDetectEntitiesItemResult.html)对象。如果处理文档时出错，则响应中的错误列表中显示记录。该示例获取了每个有错误的文档，然后重新发送它们。

本节中的 .NET 示例使用 [适用于 .NET 的 AWS SDK](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html)。您可以使用[AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/welcome.html)来开发使用.NET 的 AWS 应用程序。它包括用于部署应用程序和管理服务的有用模板和 AWS 资源管理器。有关.NET 开发人员的观点 AWS，[请参阅.NET 开发人员AWS 指南](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");
        }
    }
}
```