AWS Builder Center
Building a Real-Time Review App with Amazon Comprehend

Building a Real-Time Review App with Amazon Comprehend

Build a real-time NLP application with Amazon Comprehend and learn how to perform sentiment analysis, entity recognition, and key phrase extraction using AWS managed AI services.

Building a Real-Time Review Application with Amazon Comprehend

How I stopped using generative AI for every NLP problem and discovered a service purpose-built for text analysis.

Introduction

Natural Language Processing (NLP) has become one of the most common requirements in modern applications. Whether you're building a review platform, analyzing customer feedback, processing support tickets, or moderating user-generated content, understanding text quickly and accurately is often a core feature.
Like many developers exploring AWS AI services, my first instinct whenever I needed text analysis was to reach for Amazon Bedrock. Large Language Models such as Claude are incredibly capable, making them a natural choice for many AI-powered applications.
However, while building a restaurant review platform for places around Kathmandu, I realized I was using the wrong tool for a relatively simple task.
The requirement was straightforward:
  • Determine whether a review is positive, negative, neutral, or mixed.
  • Extract the important phrases from the review.
  • Identify entities such as people, organizations, locations, or dates.
Initially, I considered sending every review to a large language model. While this approach certainly works, it quickly became apparent that using a foundation model for basic text classification was unnecessary. Large language models excel at reasoning, generating content, answering complex questions, and engaging in conversations. For structured text analysis, AWS already provides a service designed specifically for that purpose.
That service is Amazon Comprehend.
Once I started exploring it, I realized it was exactly what I needed—simple, fast, cost-effective, and capable of returning structured data without prompt engineering or model management.
This article walks through what Amazon Comprehend is, why I chose it over an LLM for this use case, how I integrated it into a real application, and when it makes sense to use it in your own projects.

What is Amazon Comprehend?

Amazon Comprehend is a fully managed Natural Language Processing (NLP) service provided by AWS. Instead of building and training machine learning models yourself, you simply send text to an API, and Comprehend returns structured insights about that text.
Unlike generative AI services that produce human-like responses, Amazon Comprehend focuses on analyzing existing text.
This distinction is important.
Think of Amazon Bedrock as a creative writer capable of generating essays, answering questions, and reasoning through complex problems.
Think of Amazon Comprehend as an experienced analyst whose job is simply to understand text and return structured results.
There is no prompt engineering.
There is no model fine-tuning.
There are no token calculations.
You simply provide text and receive structured JSON that your application can immediately consume.

Capabilities of Amazon Comprehend

Out of the box, Amazon Comprehend provides several powerful NLP capabilities.

Sentiment Analysis

Sentiment analysis identifies the emotional tone of a piece of text.
Each document is classified into one of four categories:
  • Positive
  • Negative
  • Neutral
  • Mixed
Rather than returning only the final classification, Comprehend also provides confidence scores for each sentiment, allowing developers to understand how confident the service is in its prediction.
This is particularly useful when analyzing customer reviews, survey responses, or social media comments.

Key Phrase Detection

Often, applications need to understand what users are talking about rather than simply how they feel.
Amazon Comprehend extracts the most meaningful phrases from text and assigns confidence scores to each one.
For example, from a restaurant review, it may identify phrases such as:
  • delicious food
  • excellent service
  • rooftop seating
  • slow checkout
These extracted phrases can later be used for dashboards, search, filtering, or analytics.

Entity Recognition

Entity Detection automatically identifies important information within text.
Examples include:
  • People
  • Organizations
  • Locations
  • Dates
  • Events
  • Quantities
  • Commercial items
This capability is useful for processing contracts, resumes, customer feedback, invoices, support conversations, and many other business documents.

Language Detection

Applications often receive text written in different languages.
Instead of asking users to specify the language, Amazon Comprehend can automatically detect it.
This allows multilingual applications to route text through appropriate processing pipelines.

Personally Identifiable Information (PII) Detection

Many applications collect sensitive customer information.
Amazon Comprehend can identify items such as:
  • Email addresses
  • Phone numbers
  • Credit card numbers
  • Banking information
  • National identification numbers
This makes it easier to mask or remove sensitive information before storing or processing data further.

Why I Chose Amazon Comprehend

While working on my review application, I initially considered using Amazon Bedrock.
The workflow would have looked something like this:
  1. Send the review as a prompt.
  1. Ask the model to classify the sentiment.
  1. Parse the generated response.
  1. Convert the response into structured data.
Technically, this works.
However, it introduces unnecessary complexity.
Large language models generate natural language, meaning your application often needs to validate, clean, or parse the response before it becomes usable.
Amazon Comprehend takes a different approach.
Instead of generating text, it returns structured JSON with predictable fields every single time.
For example, sentiment is always returned as one of four predefined values:
  • POSITIVE
  • NEGATIVE
  • NEUTRAL
  • MIXED
The confidence scores always follow the same structure.
Entity detection always returns standardized object types.
Because the response format never changes, integrating it into an application becomes significantly simpler.

Building a Real-Time Review Application

To better understand how Amazon Comprehend performs in a real application, I decided to build a lightweight review platform.
The application allows users to browse locations around Kathmandu—including restaurants, cafés, hotels, and tourist destinations—and submit reviews describing their experiences.
As soon as a review is submitted, the application performs three different analyses simultaneously:
  • Sentiment Detection
  • Key Phrase Extraction
  • Entity Recognition
Within a fraction of a second, the user receives structured insights about their review.
Rather than storing only the review text, the application also stores the detected sentiment, extracted phrases, and identified entities.
This creates opportunities for richer search, filtering, reporting, and analytics without requiring any additional machine learning models.

Application Architecture

One aspect I particularly liked about this project was how simple the overall architecture became.
There is no dedicated backend service for processing reviews.
Instead, the frontend communicates directly with Amazon Comprehend using the AWS SDK.
The workflow is straightforward:
  1. The user writes a review.
  1. The frontend sends the review text to Amazon Comprehend.
  1. Three analysis APIs are executed in parallel.
  1. AWS processes each request independently.
  1. Structured JSON responses are returned.
  1. The application updates the interface with the analysis results.
Because the API calls execute concurrently, the overall response time remains extremely fast, creating a seamless user experience.

Optimizing Performance

One optimization that made a noticeable difference was executing all analysis requests in parallel.
Each Comprehend API performs an independent task.
Since none of them depend on each other's output, they can all run simultaneously.
Instead of waiting for one request to finish before starting the next, the application sends all three requests together.
This significantly reduces the total processing time and makes the interface feel almost instantaneous.
Another small optimization was reusing a single AWS SDK client instead of creating a new client for every request.
Creating SDK clients involves connection setup and credential initialization.
By creating the client once and reusing it throughout the application's lifetime, unnecessary overhead is avoided.
Although these optimizations are relatively simple, they contribute to a much smoother user experience.

Security Considerations

While building the project, one important consideration was credential management.
AWS credentials should never be hardcoded into source code or committed to Git repositories.
Instead, configuration values should be stored in environment variables and excluded from version control using  .gitignore .
For production applications, temporary credentials provided through AWS Identity and Access Management (IAM) roles or Amazon Cognito are recommended over long-lived access keys.
Following AWS security best practices helps protect both your application and your AWS account.

When Should You Use Amazon Comprehend?

Amazon Comprehend is an excellent choice whenever your application needs to understand existing text rather than generate new content.
Common use cases include:
  • Customer review analysis
  • Support ticket classification
  • Social media monitoring
  • Survey analysis
  • Content moderation
  • Business document processing
  • Entity extraction
  • PII detection before data storage
  • Analytics dashboards based on textual data
Because the service returns structured output, it integrates naturally into dashboards, reporting systems, and business intelligence pipelines.

When Should You Use Amazon Bedrock Instead?

Although Amazon Comprehend is powerful, it is not designed for every NLP problem.
If your application requires:
  • Question answering
  • Conversational AI
  • Content generation
  • Summarization
  • Code generation
  • Complex reasoning
  • Multi-step decision making
then Amazon Bedrock is the better choice.
A useful rule of thumb is:
  • Use Amazon Comprehend when you want to understand text.
  • Use Amazon Bedrock when you want to generate or reason about text.
Choosing the right service for the right task often results in lower costs, simpler code, and more predictable outputs.

Getting Started

Getting started with Amazon Comprehend requires only a few steps:
  1. Create an AWS account if you do not already have one.
  1. Create an IAM user or role with the required Amazon Comprehend permissions.
  1. Install the AWS SDK for your preferred programming language.
  1. Configure your AWS credentials securely.
  1. Call the Comprehend APIs using your application.
Within a few minutes, you can begin analyzing real-world text without training models or writing complex NLP pipelines.

Final Thoughts

Building this review application completely changed how I think about AI services on AWS.
Like many developers, I initially assumed that every NLP problem required a large language model. In reality, AWS offers specialized services designed for very specific tasks, and choosing the right one often leads to simpler architectures, better performance, and lower operational costs.
Amazon Comprehend may not generate paragraphs of text or engage in conversations, but that is precisely its strength. It focuses on one responsibility—understanding text—and delivers reliable, structured results that are easy to integrate into real-world applications.
If your application needs sentiment analysis, entity recognition, key phrase extraction, language detection, or PII identification, Amazon Comprehend is well worth exploring before reaching for a generative AI model.
Sometimes the best solution is not the most sophisticated model—it is the service purpose-built for the job.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article