Sentiment analysis on behalf of the research
The sentiment is a view or opinion which can express as an emotion or else as an attitude towards someone or something. When considering the social and business environment in the real world, most people express their thoughts and feelings openly and leads to the analysis of sentiments. Sentiment analysis helps to identify customer satisfaction towards the business. More studies carried out for the sentiment analysis, texts, sentences and paragraphs in Online conversations and feedback have used to detect the polarity. In sentiment analysis, polarity describes the orientation of the sentiments and based on the emotions expressed in the sentence.
Further, subjectivity expresses personal feelings, views or beliefs. We can have several states of polarity such as positive, negative and neutral.
There are several types of sentiment analysis which you could follow.
- Rule-based sentiment analysis: Defined rules created by humans to identify the subjectivity or polarity. The set of rules combined with computational linguistic theories will take into account, and the count of negative and positive polarized words define the negativity or positivity of the sentiment.
- Automatic sentiment analysis: Focused on machine learning-based systems. It’s freed as another classification problem and apply feature extraction, training and predicting processes.
- Hybrid sentiment analysis: Combination of both rule-based and automatic sentiment analysis. And most of the researches today is happening by using this technique.
When considering research areas related to sentiment analysis people are more tend to play with sentiments. As a result of that, they tend to analyse sequences and propagation of sentiments to obtain good results.Aspect based sentiment analysis also a method used to identify the opinions in different domain areas.
Aspect based sentiment analysis
Today in this competitive world, and people are tend to interact with technology. Most of people express their views, opinions or feelings by providing feedback towards specific place or thing. Due to high interactions, it’s hard to analyse all the feedback given in social media or forums. When analysing sentiments, it highlights all the aspects or features which people express their views in positive, neutral, or negative way. That’s the place where aspect-based sentiment analysis comes to play.
- Sentiments: positive or negative views about an aspect.
- Aspects: particular thing or topic that is being talked about.
The difference between sentiment analysis and aspect-based sentiment analysis is in sentiment analysis it detects the sentiment of the overall text, in aspect-based sentiment analysis sentiments with different aspects will consider.
In aspect analysis, by seeing the list of all nouns in a sentence or a paragraph, we can get an idea about the document. And the adjective which describes the noun helps to understand paragraph clearly. Aspect based analysis can work efficiently without any labelled data and use for topic extraction unless the sentence is not incorrect in structuring or grammatically.
Aspect-based Sentiment Analysis is decomposed as a cascade of two sub tasks:
- Aspect Category Detection (ACD)
- Aspect Category Polarity (ACP)
As mentioned above, in sentiment analysis entire text will be taken into consideration while aspect-based sentiment analysis understands the specific parts in the entire context which have sentimental value. This mechanism is highly suitable for analysing on product reviews or youtube comments etc. So let’s look more into aspect-based sentiment analysis (ABSA).
This part of the blog is going to address some situations where the readers might question about aspect-based sentiment analysis.
- How to extract aspects from the reviews or comments?
- What are the sentiment analysers which can be integrated with the aspect bases sentiment analysis?
- How to combine a deep learning model for aspect-based sentiment analysis?
- Future of the aspect-based sentiment-based analysis.
Identifying aspects and polarities of sentiments
Example 01:
Most of the people express their views towards the specific product by providing reviews or feedback which helps businesses to become customer-centric. Following experiment is conducted about the product reviews extracted from amazon.com.
Prior to feature extraction, gathered data was cleaned by using regular expressions. A noun phrase is a word or group of words which contain noun and functioning as a subject, object or prepositional object. So in here, noun phrases extract as features. Most of the times noun phrases are repeated or have the same subset of words. To overcome the above problems in the feature extraction, redundancy pruning and compact pruning is performed. Important terms in common noun phrases or largest common noun phrase can be selected for redundancy pruning. Some selected noun phrases are given below.
In here, the naive decision was used to find the largest common noun phrase as a non-redundant feature. As a simple way to carry out compact pruning is by checking the words in a phrase and seeing if a dictionary meaning exists. If the number of words in the phrase without dictionary meanings cross a certain threshold, we prune the phrase. After that noun, phrases with maximum frequencies were select as the “frequent feature set”. Then sentiment analysis was performed on feature specific sentences to get feature-based sentiment scores. For sentiment analysing textblob library have been used.
Aspect based word list and respective sentence:
In here aspects have been chosen based on the frequency of noun phrases, so some word phrases may not make sense. But carrying out the sentiment analysis on aspects provides much more information than normal sentiment analysis.
It’s obvious that the high amount of variance in the aspect based scores on the left. There is a high variance in the number of comments with positive sentiments. The total number of scores have also increased since one sentence of a comment may contain multiple frequent features.
The dot plots show a large amount of variance among sentiments across a variety of aspects.
Example 02:
As noun phrases, some have used compound words to identify aspects in specific contexts. And also used vaderSentiment for sentiment analysing.
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import operatoranalyser = SentimentIntensityAnalyzer()
sentiment = []
for i in range(len(toy_rev)):
score_dict={'pos':0,'neg':0,'neu':0}
if len(toy_rev['aspect_keywords'][i])!=0:
for aspects in toy_rev['aspect_keywords'][i]:
sent = analyser.polarity_scores(aspects)
score_dict['neg'] += sent['neg']
score_dict['pos'] += sent['pos']
#score_dict['neu'] += sent['neu']
sentiment.append(max(score_dict.items(), key=operator.itemgetter(1))[0])
else:
sentiment.append('NaN')
toy_rev['sentiment'] = sentiment
toy_rev.head()
You can see the extracted aspects and the polarity from the below .
According to below chart all roundly, this methodology also have obtained promising values.
Building up with deep learning-based aspect based model
Already annotated and published data set Semeval-2016 (Task 5) was used to develop the model. As features for the model aspects, category of aspects, sentiments and reviews were selected while the neural network architecture model is used as the aspect based classifier.
To encode the reviews in vectors, word embedding technique called Bag of words (BOW) is selected. Developed neural network model is given below
aspect_model = Sequential()
aspect_model.add(Dense(512, input_shape=(6000,), activation='relu'))
aspect_model.add((Dense(256, activation='relu')))
aspect_model.add((Dense(128, activation='relu')))
aspect_model.add(Dense(12, activation='softmax'))
#compile model
aspect_model.compile(loss='categorical_crossentropy', optimizer='Adam', metrics=['accuracy'])label_encoder = LabelEncoder()
integer_category = label_encoder.fit_transform(reviews_train.aspect_category)
encoded_y = to_categorical(integer_category)
Results of the proposed model is given below.
Contextual word representations identified by generating a representation of each word based on the other words in the sentence. As the feature of contextual representations pre-trained bidirectional language models (biLMs) have provided significant improvements to the state-of-the-art for various application areas of NLP. Also, advanced word representation techniques such as contextual word embedding have witnessed promising results. Bidirectional Encoder Representations from Transformer (BERT) is one good example of advanced contextual word embedding.
You can find the three sample for aspect based sentiment analysis from below github repository.
References
- https://medium.com/@Intellica.AI/aspect-based-sentiment-analysis-everything-you-wanted-to-know-1be41572e238--
- https://towardsdatascience.com/fine-grained-sentiment-analysis-in-python-part-1-2697bb111ed4
- https://medium.com/southpigalle/how-to-perform-better-sentiment-analysis-with-bert-ba127081eda
- https://towardsdatascience.com/beginners-guide-to-bert-for-multi-classification-task-92f5445c2d7c
- https://mc.ai/a-guide-to-simple-text-classification-with-bert/
Thanks a lot for reading up with this blog. Play with sentiment analysis …and See you in next blog post. Cheers!!!!!!