Analyze insights in text with Amazon Comprehend

How-To Guide

In this step-by-step tutorial, you learn how to use Amazon Comprehend to analyze and derive insights from text.

Amazon Comprehend is a natural language processing (NLP) service that uses machine learning to find insights and relationships in text. Amazon Comprehend uses machine learning to help you uncover the insights and relationships in your unstructured data. The service identifies the language of the text; extracts key phrases, places, people, brands, or events; understands how positive or negative the text is; analyzes text using tokenization and parts of speech; and automatically organizes a collection of text files by topic.  

In this tutorial scenario, you’re planning a trip and want to find helpful travel books. You’ve selected a book and now you want to process some reviews using Amazon Comprehend to understand if other customers found the book valuable.

In this tutorial, you learn how to:

  1. Sign in to the Amazon Comprehend console
  2. Run built-in text analysis on three customer reviews
  3. Explore insights from text analysis, including sentiment, entities, key phrases, language, and syntax
  4. Use sentiment analysis results for decision-making

The resources you create in this account are AWS Free Tier eligible.  

About this Tutorial  
Time 10 minutes
Cost AWS Free Tier Eligible
Use Case Machine Learning
Products Amazon Comprehend
Audience Developer
Level Beginner
Last Updated May 16, 2022

Step 1. Create an AWS Account

You need an AWS account to follow this tutorial. The resources you create in this account are AWS Free Tier eligible.  

Already have an account? Sign-in

Step 2. Get started with Amazon Comprehend

In this step, you sign in to Amazon Comprehend and start a real-time analysis for your book reviews.  


a. Sign in to the Amazon Comprehend in the AWS Management Console.

(Or, in the AWS Management Console, search for Comprehend, and choose Launch Amazon Comprehend.)


b. In the left navigation pane, choose Real-time analysis and scroll down to Input text. For Analysis type, choose Built-in.

The Amazon Comprehend console enables you to analyze the contents of documents up to 5,000 characters long. The results are shown in the console so that you can review the analysis. For this tutorial, you use the Built-in analysis. To learn more about the custom real-time analysis using Comprehend endpoints, see Creating an endpoint for custom classification.


In the following steps, you use Amazon Comprehend Insights to analyze these book reviews for sentiment, syntax, and more. The results of the sentiment analysis help you to determine whether these customers find the book valuable.

Review 1:
“I just wanted to find some really cool new places such as Seattle in November. I’ve never visited before but no luck here. Some of these suggestions are just terrible… I had to laugh! Most suggestions were just your typical big cities, restaurants and bars. Nothing off the beaten path here. I don’t want to go these places for fun. Totally not worth getting this.”

Review 2:
“This was such a beautiful book. I wasn’t even planning any travel when I came across this and just started flipping through the pages. I really like the cover and all the large glossy photographs in this book. John Smith did a wonderful job with the photography. I’ve found a perfect home for this on my coffee table. I’m planning a trip to Paris and Barcelona soon and I know this will come in handy. In the meantime, it’s perfect for assisting this armchair traveler!”

Review 3:
“As a traveler, I really appreciated reading about these great places to visit. The author takes you all over the world. Even with all the free information online these days, I find I’m taking this book with me wherever I go and using it to discover hidden gems.”

Step 3. Analyze text with Amazon Comprehend Insights

In this step, you use Amazon Comprehend Insights to analyze the first review for positive, negative, or mixed sentiment, entities, key phrases, language, and syntax detection.


a. In the Input text box, copy and paste the text from Review 1 and choose Analyze.

“I just wanted to find some really cool new places such as Seattle in November. I’ve never visited before but no luck here. Some of these suggestions are just terrible… I had to laugh! Most suggestions were just your typical big cities, restaurants and bars. Nothing off the beaten path here. I don’t want to go these places for fun. Totally not worth getting this.” 


b. In the Insights box, choose Sentiment.

The Sentiment tab shows the overall emotional sentiment of the text. Sentiment can be rated neutral, positive, negative, or mixed. In this case, each emotional sentiment has a confidence rating, providing an estimate by Amazon Comprehend for that sentiment being dominant. For more information, see Determine Sentiment.

For this review, the results indicate that this is a negative review, and low scores for positive or mixed sentiment.  


c. In the Insights box, choose Entities.

The Entities tab shows color-coded text to indicate different entity types such as organizations, locations, dates, and persons. The Results pane shows more information about the text. Each entry shows the entity, its category, and the level of confidence Amazon Comprehend has in this analysis. In case you want to extract custom entities, you can use Amazon Comprehend Custom Entity recognition.

You can see the entities detected along with their confidence score. For this review, Seattle has been identified as a location with a confidence score and November has been identified as a date with a confidence score.


d. In the Insights box, choose Key phrases.

The Key phrases tab lists key noun phrases that Amazon Comprehend detected in the input text and the associated confidence level. In the Analyzed text box, key phrases are indicated by underlined text. The Results section lists key phrases with the respective confidence score.

For this review, you can see multiple key phrases listed.


e. In the Insights box, choose Language.

The Language tab shows the dominant language of the text along with the confidence rating. Amazon Comprehend can recognize 100 languages. For more information, see Detect the Dominant Language.

For this review, you can see that Amazon Comprehend detected the English language with a 0.99 confidence rating.


f. In the Insights box, choose Syntax.

The Syntax tab shows a breakdown of each element in the text, along with its part of speech, and the associated confidence score. For more information, see Analyze Syntax.

Step 4. Compare results of text sentiment analyses

In this step, you repeat Step 3 to analyze the second and third reviews for positive, negative, or mixed sentiment. You can use the results to make your determination whether to buy the book! Take time to also explore additional insights, such as entities, key phrases, language, and syntax detection.


a. In the Input text box, copy and paste the text from Review 2 and choose Analyze.

“This was such a beautiful book. I wasn’t even planning any travel when I came across this and just started flipping through the pages. I really like the cover and all the large glossy photographs in this book. John Smith did a wonderful job with the photography. I’ve found a perfect home for this on my coffee table. I’m planning a trip to Paris and Barcelona soon and I know this will come in handy. In the meantime, it’s perfect for assisting this armchair traveler!”


b. In the Insights box, choose Sentiment.

You can see this second review is quite different from the first review. Here, the results are positive, and there are no negative or mixed results in this review.

Explore the additional insights from this review, and then move on to analyzing review 3.


c. In the Input text box, copy and paste the text from Review 3 and choose Analyze.

“As a traveler, I really appreciated reading about these great places to visit. The author takes you all over the world. Even with all the free information online these days, I find I’m taking this book with me wherever I go and using it to discover hidden gems.”


d. In the Insights box, choose Sentiment.

You can see this third review is much like the second. The results are positive, and there are no negative or mixed results in this review.

Out of 3 reviews, 2 have positive results. Based on these results of your sentiment analysis in this tutorial, you might want to buy that travel guide!

Congratulations

You used Amazon Comprehend to analyze and derive insights from text!

Learn more

Learn more by exploring the Amazon Comprehend Documentation.

Explore other applications for Amazon Comprehend

Learn how to use the text insights for intelligent document search or an insightful chatbot.

Explore AutoML capabilities

Learn how to use Amazon Comprehend AutoML to build custom document classifiers and entity recognizers.

Was this page helpful?