How can we use Amazon Comprehend with AWS Lambda and Amazon Lex for Sentiment Analysis (Part 1)?

Reading Time: 7 minutes

When we are asking Siri – “Hey Siri, where is the nearest grocery store?” or telling Alexa – “Alexa, can you play my workout music?”, we are actually talking to machines! These virtual assistants are examples of machines that understand human languages and respond!! Sounds interesting right? Now you must be keen to know how this is possible and which technologies are working behind it.  The answer is – AI and NLP. NLP understands and translates human language into numbers, making it easy for machines to understand. In this blog we are going to discuss NLP and one of the best NLP services – Amazon Comprehend, how it works, benefits, use cases, features, pricing, etc.

To see the full implementation of how to configure Amazon Comprehend with AWS Lambda and Amazon Lex for sentiment analysis to create interactive, efficient, and helpful Amazon Lex bots, refer to Part 2 of the blog here.

In this blog, we will cover:

  • What is Natural Language Processing (NLP)?
  • What is Amazon Comprehend?
  • How does it work?
  • Who can use Amazon Comprehend?
  • Benefits of Amazon Comprehend
  • Common use cases of Amazon Comprehend
  • Features of Amazon Comprehend
  • Pricing
  • Companies using Amazon Comprehend
  • Conclusion

What is Natural Language Processing?

Artificial intelligence (AI), Machine Learning(ML), and Natural Language Processing (NLP) are buzzwords and are sometimes used interchangeably! They have a major impact on countless functions across numerous industries. 

NLP is an area of artificial intelligence that allows computers to interpret human language.

Amazon Comprehend

Some well-known applications of NLP are virtual assistants like Siri & Alexa, chatbots, etc. There are many other apps that you use frequently, where you’ve probably encountered NLP without even noticing. Some examples like Gmail offering to translate a mail written in a different language, text recommendations when writing an email, offering to translate a Facebook post written in a different language, or filtering unwanted promotional emails into your spam folder.  

Human language is extremely diverse, ambiguous, and complex. The goal of NLP is to make human language easy for machines to understand.

Now the question is how does NLP work? First, it applies linguistics to analyze the grammatical structure and the meaning of words, then it uses algorithms to build intelligent systems capable of performing different tasks.  

Amazon Comprehend

Natural language processing(NLP) is a revolutionary new solution that is helping to enhance insights and get even more visibility into all facets of customer-facing operations than ever before. NLP utilizes AI and machine learning to extract meaning from text. Natural language processing can analyze, extract meaning from, and determine actionable insights from the following in text. 

NLP Techniques 

Natural Language Processing (NLP) applies the following  two techniques to help computers understand text:

  • Syntax analysis: NLP uses grammatical rules to determine a language’s meaning. Word segmentation, sentence breaking, morphological segmentation, and stemming are examples of NLP syntax approaches that are commonly used.
  • Semantics analysis: Using algorithms to grasp the content and structure of phrases, NLP can also determine meaning and context from language. Word sense disambiguation, named entity identification, and natural language production are all examples of semantics approaches used in NLP.

What is Amazon Comprehend?

Amazon Comprehend is a natural language processing (NLP) service that uses machine learning to find insights and relationships in text and in unstructured data. In real-time, you can automatically and accurately detect customer sentiment in your content. It has a powerful behind-the-scenes machine-learning model and can be used without any prior Machine Learning experience. Comprehend is fully managed, so you can get up and running quickly, without having to train models from scratch. Start processing millions of documents in minutes by leveraging the power of machine learning.

What is Amazon Comprehend?

How does it work?

Amazon Comprehend is called on a synchronous basis to extract key phrases in the following steps:

  • The incoming text file uploaded to the NLP/Textract S3 bucket invokes the Sync Comprehend Processor Lambda function.
  • The function feeds the incoming file to Amazon Comprehend for processing.
  • The results from Amazon Comprehend, in JSON format, are deposited in the NLP/JSON S3 bucket.
  • The results from Amazon Comprehend are sent to Amazon ES, the service we incorporate as our document search engine.
Amazon Comprehend

All steps are registered in metadata services. The red dotted lines in the diagram represent the metadata asynchronous API calls.

Who can use Amazon Comprehend?

You don’t need to have natural language processing (NLP) expertise to use Amazon Comprehend. You only need to call Amazon Comprehend API, and the service will handle the machine learning required to extract the relevant data from the text. 

Amazon Comprehend

Amazon Comprehend uses machine learning and is continuously being trained to make it better for your use cases. You can also feed it a set of text documents, and it will identify topics (or groups of words) that best represent the information in the collection.

Benefits of Amazon Comprehend

Benefits of Amazon Comprehend
  • Train models on your own data: Used to identify specific terms. You can tailor the classification messages and documents to your organization’s needs, such as social media posts by product. It’s as simple as providing the labels and a small set of examples of each.
  • Uncover valuable insights from your text: Uncover the meaning and relationships in text from customer support incidents, product reviews, social media feeds, news articles, documents, and other sources.
  • Support for general and industry-specific text: Can identify industry-specific insights from unstructured text and documents, like emails. Amazon Comprehend Medical can identify medical information, such as medication and medical conditions, from a variety of sources (including doctor’s notes), and determine their relationship to each other. It enables easier analysis and provides context, to make extracted terms meaningful.
  • Organize documents by topics: Can be trained to label documents with topics or tags defined by you. Natural Language Processing techniques enable the solution to go beyond keyword search or rules-based tagging for more accurate document classification. Deliver personalized content to your customers and provide richer navigation based on these topics.

Common Use Cases of Amazon Comprehend

  • Customer Analytics 
  • Accurate Search
  • Knowledge Management 
Common Use Cases of Amazon Comprehend
  • Support Tickets
Common Use Cases of Amazon Comprehend
  • Medical Cohort Analysis
Common Use Cases of Amazon Comprehend

Features of Amazon Comprehend

Features of Amazon Comprehend
  • Keyphrase Extraction: The Key Extraction API gives key phrases or talking points, as well as a confidence level indicating whether or not this is a key phrase.
  • Sentiment Analysis: The Sentiment Analysis API provides a summary of a text’s overall sentiment (Positive, Negative, Neutral, or Mixed).
  • Custom Entities: With Custom Entities, you may tailor Amazon Comprehend to find phrases that are unique to your domain. Comprehend will utilise AutoML to learn from a tiny private index of instances (for example, a list of policy numbers and the text in which they appear) and then train a private, bespoke model.
  • Syntax Analysis: Customers may use the Amazon Comprehend Syntax API to analyse text using tokenization and Parts of Speech (PoS), as well as detect word boundaries and labels such as nouns and adjectives.
  • Entity Recognition: The Entity Recognition API delivers named entities (“People,” “Places,” “Locations,” and so on) that have been automatically classified based on the input text.
  • Language Detection: The Language Detection API detects text written in over 100 languages and delivers the prevailing language along with a confidence score to back the assertion that a language is dominant.
  • Custom Categorization: With the Custom Classification API, you can quickly create custom text classification models based on your company’s labels.
  • Topic Modeling: From a collection of documents stored in Amazon S3, Topic Modeling extracts relevant phrases or subjects. It will find the collection’s most prevalent subjects, group them together, and then map which documents belong to this topic.
  • Multiple Language Support: Amazon Comprehend can analyse texts in English, French, German, Italian, Portuguese, and Spanish. This allows you to create apps that can identify text in many languages, translate it to English, French, German, Italian, Portuguese, and Spanish using Amazon Translate, and then do text analysis using Amazon Comprehend.

Pricing

Companies using Amazon Comprehend

Conclusion

In this blog, we have discussed NLP and Amazon Comprehend as one of the best NLP services. You understood that NLP works behind the scenes to enhance tools you use every day, like chatbots, spell-checkers, or language translators. In part 2 of this blog, we will be demonstrating how we can integrate Amazon Comprehend with AWS Lambda function and Amazon Lex bot to create an efficient and helpful bot. We will implement the sentiment analysis feature for the bot via Lambda Function integrating it with Amazon Comprehend. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies.

Meanwhile …

Keep Exploring -> Keep Learning -> Keep Mastering

This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At Workfall, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you’re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at workfall.com/partner today.

Back To Top