Active Hackathon

Social Media Monitoring: Emotional Analysis Using text2emotion In Python

In today’s digital world every brand knows how important social media has become for them to drive their businesses. Every brand tries to get sales or conversions of its products or services by driving its potential customers emotionally on social media through Ads, Posts, videos, memes, etc. Have you ever thought how useful it would be for your business to know the emotions of your customers about your product by analyzing the feedback or comments from your social media posts? This article gives you an idea of the same using text2emotion, a python package developed by me along with three of my colleagues.

Table of Contents:

  1. Text2Emotion
  2. Social Media Monitoring
  3. Working of Text2Emotion
  4. How to use it?
  5. Key Takeaways

1. Text2Emotion:

It helps you in classifying the tone of the text by categorizing it into five different emotions as Happy, Angry, Surprise, Sad, and Fear.


Sign up for your weekly dose of what's up in emerging technology.

Key Features:

  • Processes any textual message and recognizes the emotions embedded in it.
  • Compatible with 5 different emotion categories as Happy, Angry, Sad, Fear, and Surprise.

2. Social Media Monitoring:

Let us now look at an Industrial use case where analyzing emotions from text plays a vital role to give us more clarity on this topic.

In today’s digital world Brand Monitoring and reputation management has become one of the most important aspects of every business unit. This is where emotion analysis plays a vital role. Understanding how the end-users or customers recognize your brand or product is very useful for every company and organization. 

We can implement the text2emotion package to create a software that brings flexibility into the business by giving information about the perception of a brand by the end users and gives more insight into the reputation of the company and its products. It will help companies by allowing them:

  • In tracking the perception of the company by the consumers.
  • In pointing out the attitude of the consumers by giving specific details.
  • Finding different patterns and trends.
  • In keeping a close look on the demonstration by the influencers.

All this helps us in modifying our product and services according to the need of the customers and generate more revenue.

3. Working of Text2Emotion:

Let us now look at the working of this package.


In the first step, our aim is to remove all the impurities or unwanted things from our data by data cleaning so that it can become suitable for emotion analysis.

  • Remove the unwanted textual part from the content.
  • Perform natural language processing techniques.
  • Obtain the well-pre-processed text after the text pre-processing.


In the second step, we will identify the different emotions from the words obtained from pre-processed text and will keep a count of each and every emotion.

  • Find those words which appropriately express emotions or feelings.
  • Inspect the emotion category for each word.
  • Store the count of all the emotions relevant to all the words which were found.


After the completion of Emotion Identification, we need to analyze the emotions in order to get proper output for the input message.

  • We will obtain the output in a dictionary form.
  • The keys will be in the form of emotion categories and their values in the form of emotion scores.
  • We can decide the category to which a particular message belongs by analyzing the highest score of a particular emotion category.

4. How to use it?

Check Google Collab Demo:

Google Collab : text2emotion

App Demo

Below given is the demo of code implementation with Streamlit App for the users.

  1. Enter the text message.

Enter the text message in the box and click on the submit button.

2. Click the submit button.

3. Bingo! Get the output of your message in visual form.

It identifies the emotions in the text and gives you output in visual form accordingly.

Check Demo Web App here

Let’s get hands-on experience in the library.

For more information visit:

text2emotion Documentation

5. Key Takeaways

Altogether, text2emotion can be used:

  • In automating the social media monitoring process.
  • In monitoring mentions or reviews of the brand on different social media platforms like Facebook, Twitter, Instagram, etc.
  • In categorizing different reviews of the customers and knowing which social media platform and which type of user is important for the company.

More Great AIM Stories

Shivam Ravikumar Sharma
Software Developer and Machine Learning Enthusiast

Our Upcoming Events

Conference, Virtual
Genpact Analytics Career Day
3rd Sep

Conference, in-person (Bangalore)
Cypher 2022
21-23rd Sep

Conference, in-person (Bangalore)
Machine Learning Developers Summit (MLDS) 2023
19-20th Jan

Conference, in-person (Bangalore)
Data Engineering Summit (DES) 2023
21st Apr, 2023

3 Ways to Join our Community

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Telegram Channel

Discover special offers, top stories, upcoming events, and more.

Subscribe to our newsletter

Get the latest updates from AIM

The curious case of Google Cloud revenue

Porat had earlier said that Google Cloud was putting in money to make more money, but even with the bucket-loads of money that it was making, profitability was still elusive.

Global Parliaments can do much more with Artificial Intelligence

The world is using AI to enhance the performance of its policymakers. India, too, has launched its own machine learning system NeVA, which at the moment is not fully implemented across the nation. How can we learn and adopt from the advancement in the Parliaments around the world? 

Why IISc wins?

IISc was selected as the world’s top research university, trumping some of the top Ivy League colleges in the QS World University Rankings 2022