AWS Code Sample


DetectSentiment.cs demonstrates how to detect sentiment in a given sample string using the Comprehend client.

using System; using Amazon.Comprehend; using Amazon.Comprehend.Model; namespace ComprehendSamples1 { class DetectSentiment { 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 DetectSentiment"); var detectSentimentRequest = new DetectSentimentRequest() { Text = text, LanguageCode = "en" }; var detectSentimentResponse = comprehendClient.DetectSentiment(detectSentimentRequest); Console.WriteLine(detectSentimentResponse.Sentiment); Console.WriteLine("Done"); } } }

Sample Details

Service: comprehend

Author: AWS

Type: full-example

On this page: