While exploring AWS, I came across this Machine Learning product - Amazon Comprehend and thought about writing this article, on how you can use this service to get insights and relationships from the customers texts.
Amazon Comprehend
The service identifies the sentiment of the text;
It also extracts key phrases, places, people from the text;
Understands how positive or negative the text is;
Analyzes text using tokenization and parts of speech;
and automatically will return a confidence score for each result.
Use cases
You can sense whether the customer's sentiment is positive, neutral or mixed on the feedback you get from the customer's calls and emails and then analyze and organize them by topic, so that you can use them to personalize content for your customers to improve the rate of the outcomes in less time.
For this project, I was looking for some good songs. You’ve selected a song and now you want to see what results you would expect using Amazon Comprehend and what if other people also found the song to be good.
Please visit my GitHub Repository for Machine Learning articles on various topics being updated on constant basis.
Let’s get started!
Objectives:
1. Have 3 reviews ready for this article
2. Run built-in text analysis on Review 1
3. For Review 1, analyze text with Amazon Comprehend Insights, including sentiment, entities, key phrases, language, and syntax
4. For Review 2 and Review 3, analyze text with Amazon Comprehend Insights, sentiment only.
5. Compare results of text and use sentiment analysis results for decision-making
Pre-requisites:
- AWS user account with admin access, not a root account.
Resources Used:
Amazon Comprehend Documentation
Steps for implementation to this project:
1. Have 3 reviews ready for this article
- Review 1
I am looking for a song to add to my playlist of romantic songs from the 1950s. I am looking on YouTube for a suitable song. I am planning to use this playlist at a dinner party that I am having in a few days.
- Review 2
I found a song. It is sung by Lata Mangerhkar. The name of the song is Rasik Balma from the movie Chori Chori. The music directors were Shankar-Jaikishan and the lyricist was Hasrat Jaipuri.
- Review 3
I really like this song. It really conveys the intense sadness that a person feels when they are separated from their beloved. I think everyone at the dinner party will also like it.
2. Run built-in text analysis on Review 1
On Amazon Comprehend console / In the left navigation pane, choose Real-time analysis / scroll down to Input text / For Analysis type, choose Built-in
You can write up to 5000 characters long in the text document. The results are shown in the console so that you can review the analysis. For this article, I am using the Built-in analysis.
3. For Review 1, analyze text with Amazon Comprehend Insights, including sentiment, entities, key phrases, language, and syntax
- Copy and paste Review 1 into the Input text
I am looking for a song to add to my playlist of romantic songs from the 1950s. I am looking on YouTube for a suitable song. I am planning to use this playlist at a dinner party that I am having in a few days.
choose Analyze
In the Insights box, choose Sentiment
The Sentiment tab shows the overall emotional sentiment of the text.
Sentiment is 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 this Review 1, the results indicate that this is not a negative review, but has low scores for positive and neutral sentiment.
In the Insights box, choose Entities
The Entities tab shows color-coded text to indicate different entity types such as organizations, and dates.
The Results pane shows more information about the text.
Each entry shows the entity, its category, and the level of confidence.
For this Review 1, 1950's has been identified as a Date with a confidence score and YouTube has been identified as a Organization with a confidence score.
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 shown by underlined text.
The Results section lists key phrases with the respective confidence score.
For this Review 1, you can see multiple key phrases listed.
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 this Review 1, English language has a 0.99 confidence rating.
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.
4. For Review 2 and Review 3, analyze text with Amazon Comprehend Insights, sentiment only.
- Copy and paste Review 2 into the Input text
I found a song. It is sung by Lata Mangerhkar. The name of the song is Rasik Balma from the movie Chori Chori. The music directors were Shankar-Jaikishan and the lyricist was Hasrat Jaipuri.
choose Analyze
In the Insights box, choose Sentiment
The Sentiment tab shows the overall emotional sentiment of the text.
Sentiment is 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 this Review 2, the results indicate that neutral sentiment has 0.99 confidence score
- Copy and paste Review 3 into the Input text
I really like this song. It really conveys the intense sadness that a person feels when they are separated from their beloved. I think everyone at the dinner party will also like it.
choose Analyze
The Sentiment tab shows the overall emotional sentiment of the text.
Sentiment is 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 this Review 3, the results indicate that positive sentiment has 0.99 confidence score
5. Compare results of text and use sentiment analysis results for decision-making
By comparing the sentiment analysis images for the 3 reviews, we got these results
From Review 1
- The results indicate that this is not a negative review, but has
low scores for positive and neutral sentiment
From Review 2
- the results indicate that
neutral sentiment has 0.99 confidence score
From Review 3
- the results indicate that
positive sentiment has 0.99 confidence score
Cleanup
- Clear text from the Input text box.
What we have done so far
We have successfully used Amazon Comprehend service to get insights and relationships from the customers texts.
Top comments (0)