# Sentiment Analysis

## Summary


Sentiment Analysis is a process which focuses on analyzing people’s opinions, feelings, and attitudes towards a specific product, organization or service. 

It is not uncommon for us to consider what other people think in our decision-making process. Prior to the advent of the Internet, many of us relied on friends and families for product or service recommendations, or information when buying a product. The Internet eases our efforts to get opinions of the general population. 

In a world where colossal amounts of user-generated content is produced every day, it is practically impossible for human workforce to collect all the data and determine the opinions expressed in those data. Therefore, there arises a need to develop computer algorithms to automate the classification of reviews on the basis of their polarities as: positive, negative or neutral.

## Discussion

### What kind of questions are answered by Sentiment Analysis?

Since Sentiment Analysis tools classify a sample of text as positive, negative or neutral, some of the questions which can be answered using Sentiment Analysis are as follows:  

    + Is a given product review positive or negative?
    + Is a customer satisfied or dissatisfied based on his email response?
    + Based on a sample of tweets, how are people responding to a given ad campaign, product release, or news item?
    + How have bloggers' attitudes about the president changed since the election?

### What are the steps involved in Sentiment Analysis?

Sentiment analysis typically has the following steps: 

    + **Data acquisition:** The collection of data is an important phase since a proper dataset needs to be defined for analyzing and classifying the text in the dataset.
    + **Text preprocessing**: After collecting the data, preprocessing allows to reduce noise in data. This is done by removing the unnecessary stop words, repeated words, stemming, removal of emoticons, removal of URLs etc.
    + **Feature selection and extraction:** Proper selection and extraction of features plays a key role in determining the accuracy of the model. Hence, the appropriate feature extraction technique must be chosen for extracting the features.
    + **Sentiment classification:** In this phase, various sentiment classification techniques are applied to classify the text. Some popular sentiment classification techniques are Naïve Bayes (NB) and Support Vector Machines(SVM).
    + **Polarity detection:** After classifying the sentiments, the polarity of the sentiment is determined. The goal of polarity detection is to decide whether a text expresses positive, negative or neutral sentiment.
    + **Validation and evaluation**: Finally, validation and evaluation of the obtained results is performed so as to determine the overall accuracy of the techniques used for sentiment analysis.

### What are the various approaches for sentiment analysis?

Broadly, there are ML-based and lexicon-based approaches, plus a hybrid approach that's a combination of these two.

**ML models** classify the text as positive, negative or neutral using classification algorithms and linguistic features. 

**Lexicon models** make use of sentiment lexicons, which are collections of annotated and preprocessed sentiment terms. Sentiment values are assigned to words that describe the positive, negative and neutral attitude of the speaker. It is further classified as: 

    + *Dictionary-based Method*: It uses a small set of seed words and an online dictionary. The strategy here is initial seed set of words with their known orientations are collected and then online dictionaries are searched to find their probable synonyms and antonyms. The sample is classified based on the presence of such signalling sentiment words.
    + *Corpus-based Method*: Uses corpus data to identify sentiment words. Even though it is not as effective as dictionary based scheme, it is helpful in finding the domain and context of specific sentiment words against the corpus data. The algorithm will have access not only to sentiment labels, but also to a context.

### What are the advantages and limitations of the Sentiment Analysis approaches?

*Machine Learning based* 

    + **Advantage**: Unlike Lexicon-based, these models can be built for a specific purpose or context.
    + **Limitation**: Obtaining labeled data for training could be difficult or expensive.*Lexicon-based* 

    + **Advantage**: No training is required.
    + **Limitation**: Accuracy depends on lexical resources. Finite number of words in lexicons and the assignment of a fixed sentiment orientation and score to words.*Hybrid:* 

    + **Advantage**: It incorporates the best of Machine learning based and Lexicon based approaches.Generally, Machine Learning based models perform better than Lexicon-based models. But Machine Learning models require labeled data in huge quantities. 


### What are some tools available for Sentiment Analysis at present?

Here are some developer tools for sentiment analysis: 

    + Python NLTK: A python based tool for text processing, cataloging, tokenization, stopping, tagging, parsing and much more.
    + GATE, the General Architecture for Text Engineering: A Java suite of tools used for all sorts of natural language processing tasks, including information extraction in many languages.
    + LingPipe: LingPipe is tool kit for processing text using computational linguistics.
    + LIWC (Linguistic Inquiry and Word Count): A computerized text analysis tool that reads a given text and counts the percentage of words that reflect different emotions, thinking styles and social concerns.Among other tools are Opinion Finder, Grooper document classification, MonkeyLearn, IBM Watson, Lexalytics, MeaningCloud, Rosette, Repustate, Clarabridge and Aylien. 


### What are the challenges involved in Sentiment Analysis?

Human language is intricate. People often express opinions in complex ways. To mention a few: 

    + **Named entity recognition**: Locating and classifying named entities in text into pre-defined categories such as the names of persons, organizations, locations. Eg: Is 300 Spartans a group of Greeks or a movie?
    + **Anaphora Resolution**: It is the problem of resolving references to earlier or later items in the discourse. Eg: "We watched the movie and went to dinner. It was awful." What does "It" refer to?
    + **Parsing**: This refers to resolving a sentence into its component parts. What is the subject and object of the sentence, which one does the verb and/or adjective actually refer to?
    + **Rhetorical modes**: Typically the analysed posts contain sarcasm, irony, implication, etc, which are particularly difficult to detect.
    + **Social media website**: It is not uncommon to find reviews and opinions containing slang, abbreviations, lack of capitals and poor punctuation, which would make sentiment analysis even more challenging.
    + **Visual sentiment analysis**: Posts often contain a mixture of visual and textual information. The sentiment polarities implied by texts may contradict the sentiments of images, which poses a challenge for textual sentiment analysis.

### Where is Sentiment Analysis being used at present?

A very broad answer to this can be broken up into three categories:

    + **Brand Monitoring** - Sentiment Analysis is used to gauge how a brand, product or company has been received by the public. In fact, private companies like Unamo offer this as a service.
    + **Customer Service** - Customer service agents classify incoming mail into 'urgent' and 'non-urgent', in order to be able to serve the more frustrated customers quicker. The speech analytics platform Callminer Eureka implements AI and ML techniques to draw insight from consumer interactions, in order to offer quality customer service.
    + **Market Research and Analysis** - Opinion mining plays a crucial role in business intelligence, by helping analysts understand why a particular product was well received or not. Stock markets and hedge funds have been known to shift with the shift in sentiments on social media.Sentiment analysis has also driven forward various other initiatives. Bing Search used the concept in their newly launched Multi-Perspective Answers product. 

Apart from the above, Sentiment analysis is used in the areas of political science, sociology, psychology; flame detection, identifying child-suitability of videos, bias identification in news sources are the variety of applications. 

## Milestones

300  
BC

The history of Sentiment Analysis begins in Ancient Greece with the concept of *Doxa*, which refers to common belief or popular opinion. 

1824

The Harrisburg Pennsylvanian conducts a "straw polling" to predict the outcome of the United States presidential election. The prediction turns out to be incorrect, possibly because it didn't draw the right sample. 

1997

Hatzivassiloglou and McKeown use the term **semantic orientation** in a paper titled *Predicting the Semantic Orientation of Adjectives*. Their approach is corpus-based and adapts to new domains. Thus it can tell that 'bull' and 'bear' are opposites in stock market reports. Using only adjectives, their model achieves 90% precision. 

2004

Pang and Lee apply machine learning to sentiment analysis. They propose a subjectivity detector to pick out subjective sentences. Then they employ text categorization techniques on the subjective sentences. Algorithms used include Naive Bayes and SVM to find minimum cuts in a graph. They claim an accuracy of 86.4% on the NB polarity classifier. 

2005

Gruhl et al. conduct one of the first studies to determine if online comments influence the sales figures of a product. They obtain the sales data of books from Amazon.com. From blog mentions and online chatter, they use automated query generation algorithms to predict the rise and fall of sales of certain books. They find that positive comments lead to increased sales. 

Mar  
2011

The shares of Buffet-owned Berkshire Hathaway rises by as much as 2.94% following the Oscars award ceremony. Likewise, there' correlation between Anne Hathaway's movie release dates and stock price increases of Berkshire Hathaway during the period 2008-2010. The reasoning is that automated trading programs are picking up online chatter about 'Hathaway' and applying it to the stock markets. This is an example where sentiment analysis fails to understand context. 

2012

Kucuktunc et al. pioneer large-scale sentiment analysis of Yahoo! Answers. They find that answers differ according to the attributes of users, such as best-rated answers have a neutral tone to them. They also identify particular feelings evoked on reading a certain question. These findings begin to be used in advertising and recommendations. 

Jun  
2014

Aleksandr Kogan collects and provides a database containing information of about 87 million Facebook users to Cambridge Analytica. Cambridge Analytica subsequently uses it to make 30 million "psychographic" profiles about voters. In later years, it is alleged that this data was used to influence voter opinion on behalf of politicians who hired them. 

2017

Poria et al. identify the sentiments present in online videos based on utterances. An utterance is a unit of speech bound by a pause. Each utterance is classified subjectively. 

2019

Sun et al. apply **BERT**, a pre-trained neural network language model, to the task of Aspect-Based Sentiment Analysis (ABSA). Another research group also applies BERT to ABSA to show state-of-the-art results on SemEval-2015 Task 12 subtask 2 and SemEval-2016 Task 5.