Skip to main content
Version: 2.0

Analyze the sentiments of online reviews


Why analyze online reviews?

The amount of reviews posted online, whether about a restaurant, a product or a brand, has exploded over the last decade. Consulting these reviews has become automatic for consumers and greatly influences their purchasing decisions (according to a BrightLocal study, 87% of consumers consult online reviews to buy a product or service). It is therefore crucial for B2C companies to take control of these reviews and exploit their full potential. This requires tedious analysis work for marketing teams, which is all the more complex as the number of online review sources multiplies.

What are the main obstacles to auditing online customer verbatims?

  • too many reviews for an exhaustive analysis of the information
  • multiple channels/platforms for collecting online reviews


Department store looking to improve the customer online shopping experience. Does customer support need to be reinforced, is product quality control adequate are our product descriptions accurate? These are just a few question that could be answered more easily by analyzing customer reviews to determine whether the customers are feeling positive, negative or neutral by filtering the polarity of the reviews.

Collecting your data

The reviews I am using come from multiple products and will give a global sentiment of our reviews. The file is in CSV format.

After you have installed the Lettria SDK, imported the library and added your personal API key you can add your data.

Filtering polarity

The filter polarity tool returns a list of sentences from the polarity and sentence or subsentence specified. You can take the analysis further and modify the polarity and the granularity to obtain the results you need.

Getting emotions

With the polarity results, I can take the analysis a step further to extract the exact emotions from the reviews to better understand how the customers are feeling. Like polarity, you can also take the analysis further and modify the granularity to obtain the results you need.

Filtering emotions

Once you have obtained the emotions from your reviews you can use the filter emotion tool to filter out specific emotions to target the reviews that need more attention. You can also modify the granularity for further analysis.

Code set

import lettria

api_key = 'your personal API key'
nlp = lettria.NLP(api_key)

with open("example.txt", "r") as f:
example_data = f.readlines()


filter_polarity = nlp.filter_polarity
filter_polarity(polarity='positive', granularity='sentence')

filter_polarity(polarity=‘negative’, granularity=‘subsentence')

get_emotion = nlp.get_emotion
get_emotion(granularity = 'sentence')

filter_emotion = nlp.filter_emotion
filter_emotion(emotions='surprise', granularity='sentence')