AWS Code Sample
Catalog

DetectKeyPhrase.cs

DetectKeyPhrase demonstrates how to detect key phrases in a given string using the Comprehend client.

using System; using Amazon.Comprehend; using Amazon.Comprehend.Model; namespace ComprehendSamples1 { class DetectKeyPhrases { public static void Sample() { String text = "It is raining today in Seattle"; var comprehendClient = new AmazonComprehendClient(Amazon.RegionEndpoint.USWest2); // Call DetectKeyPhrases API Console.WriteLine("Calling DetectKeyPhrases"); var detectKeyPhrasesRequest = new DetectKeyPhrasesRequest() { Text = text, LanguageCode = "en" }; var detectKeyPhrasesResponse = comprehendClient.DetectKeyPhrases(detectKeyPhrasesRequest); foreach (var kp in detectKeyPhrasesResponse.KeyPhrases) Console.WriteLine("Text: {1}, Type: {1}, BeginOffset: {2}, EndOffset: {3}", kp.Text, kp.Text, kp.BeginOffset, kp.EndOffset); Console.WriteLine("Done"); } } }

Sample Details

Service: comprehend

Author: AWS

Type: full-example

On this page: