Sentiment Analysis is used to analyse the emotion of the text. In other words, it is the process of detecting a positive or negative emotion of a text.
So, putting it in simple words, by using sentiment analysis we can detect whether the given sentence, paragraph or a document contains a positive or negative emotion/opinion in it.
Use-Case of Sentiment Analysis
Since customer nowadays is open and more abrupt in expressing their views about the products or services they use, sentiment analysis becomes an essential tool for the companies to know their customers in-depth and better.
Sign up for your weekly dose of what's up in emerging technology.
Sentiment Analysis enables companies to know what kind of emotion/sentiment do customers have for them. This can play a huge role because companies can improve their products/services based on the analysis of customer sentiments.
Challenges Faced During Analysis of Sentiments
You might be thinking that a sentence having positive or good words will be analysed as positive sentiment & vice-versa a sentence having negative words will be analysed as the negative sentiment.
Download our Mobile App
While the challenge here is that different people write their opinions in different ways, some people express their opinion straight while some may prefer adding sarcasm to their opinion. Also, some might have both positive and negative opinions.
For example: “This car is good but its mileage could’ve been better”
In the above scenario, the opinion of a user is on both sides. But we have a good solution for this situation which can to some extent can make our analysis easier. Let’s have a look at it in the upcoming paragraph.
VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media.
It is used for sentiment analysis of text which has both the polarities i.e. positive/negative. VADER is used to quantify how much of positive or negative emotion the text has and also the intensity of emotion.
Here are the advantages of using VADER which makes a lot of things easier:
- It does not require any training data.
- It can very well understand the sentiment of a text containing emoticons, slangs, conjunctions, capital words, punctuations and much more.
- It works excellent on social media text.
- VADER can work with multiple domains.
Let’s start analysing the sentiment using VADER.
First, let’s install VADER from https://pypi.org/project/vaderSentiment/ by using the command line:
pip install vaderSentiment
Now, let’s start writing our script:
Here, SentimentIntensityAnalyzer() is an object and polarity_scores is a method which will give us scores of the following categories:
The compound score is the sum of positive, negative & neutral scores which is then normalized between -1(most extreme negative) and +1 (most extreme positive).
The more Compound score closer to +1, the higher the positivity of the text.
Above text is 49.2% Positive, 0% Negative, 50.8% Neutral. While the compound score is 44.04%.
Let’s look at some examples
In the above scenario we can see that with the use of conjunction in a sentence, the positive & compound score has decreased.
In this scenario, with the use of smiley (emoji) in a sentence, the positive score and compound score has increased.
Here we can see that with the use of capital word & exclamation mark, the positive score & compound score has increased.
The second sentence is more intense, positive and so the compound score of the second sentence is more.
The compound score will increase as the intensity of the text will increase towards positive.
VADER classifies the sentiments very well. It is easy to use, the ready-made model which can be used across multiple domains, social-media texts, analysing reviews etc. The cherry on the cake when using VADER is it does not require any training data. Well, we can see that the results obtained are very excellent!!