What is sentiment analysis?
A kind of text classification.
Is a movie review good or bad?
Product search
Twitter sentiment vs Gallup poll of consumer confidence
Twitter mood predicts the stock market
Target sentiment on Twitter – Twitter sentiment app
Sentiment analysis has many other names
-opinion extraction
-opinion mining
-sentiment mining
-subjectivity analysis
Why sentiment analysis?
-movie: is this review positive or negative?
-products: what de people think about the new iPhone?
-public sentiment: how is consumer confidence? is despair increasing?
-politics: what do people think about this candidate or issue?
-prediction: predict election outcomes or market trends from sentiment
Scherer typology of affective states
Emotion: brief organically synchronized … evaluation of major event
-angry, sad, joyful, fearful
Mood: diffuse non-caused low-intensity long-duration change in subjective feeling
-cheerful, gloomy, irritable
Interpersonal stances: affective stance toward another person in a specific interaction
-friendly, distant, supportive, cold
Attitudes: enduring, affectively colored beliefs, dispositions towards objects or persons
-liking, loving, hating, valuing
Personality traits: stable personality dispositions and typical behaviour tendencies
-nervous, anxious, reckless, morose
Sentiment analysis is the detection of attitudes
1. Holder (source) of attitude
2. Target (aspect) of attitude
3. Type of attitude
-from a set of types, like, love, hate, value, desire, etc.
-or (more commonly) simple weighted polarity, positive, negative, neutral together with strength
4. Text containing the attitude
-sentence or entire document
Simplest task: Is the attitude of this text positive or negative?
More complex: Rank the attitude of this text from 1 to 5
Advanced: Detect the target, source or complex attitude types
A baseline algorithm
Sentiment classification in movie reviews
Polarity detection: Is and IMDB movie review positive or negative?
Data: Polarity Data 2.0 (http://www.cs.cornell.edu/people/pabo/movie-review-data)
Baseline algorithm (adapted from Pang and Lee)
Tokenization
Feature extraction
Classification using different classifiers (Naive Bayes, MaxEnt, SVM)
Sentiment tokenization issues
Deal with HTML and XML markup
Twitter mark-ups (names, hash tags)
Capitalization (preserve for words in all caps)
Phone numbers, dates
Emoticons
Usefule code:
Christopher Potts sentiment tokenizer
Brendan O’Connor twitter tokenizer
Extracting features for sentiment classification
How to handle negation
Which words to use?
Negation
Add NOT_ to every word between negation and following punctuation:
didn’t like this movie, but I
didn’t NOT_like NOT_this NOT_movie, but I
Binarized (Boolean feature) multinomial Naive Bayes
Intuition:
For sentiment (and probably for other text classification domains) word occurrence may matter more than word frequency.
-the occurrence of the word fantastic tells us a lot
-the fact that it occurs 5 times may not tell us much more
Boolean multinomial Naive Bayes clips all the word counts in each document at 1.
Binary seems to work better than full word counts
Other possibility: log(freq(w))
Cross-Validation
Break up data into 10 folds (equal positive and negative inside each fold?)
For each fold, choose the fold as a temporary test set. Train on 9 folds, compute performance on the test fold.
Report average performance of the 10 runs.
Other issues in classification
MaxEnt and SVM then to do better than Naive Bayes
Problems: What makes reviews hard to classify?
Subtlety
Review in Perfumes: the Guide: “If you are reading this because it is your darling fragrance, please wear it at home exclusively, and tape the windows shut.”
Dorothy Parker on Katherine Hepburn: “She runs the gamut of emotions from A to B.”
Thwarted expectations and ordering effects
“This film should be brilliant. It sounds like a great plot, the actors are first grade … However, it can’t hold up.”
“Well as usual Keanu Reeves is nothing special, but surprisingly, the very talented Laurence Fishbourne is not so good either, I was surprised.”
Sentiment lexicons
The General Inquirer (free for research use)
Home page: http://www.wjh.harvard.edu/~inquirer
List of categories: http://www.wjh.harvard.edu/~inquirer/homecat.htm
Spreadsheet: http://www.wjh.harvard.edu/~inquirer/inquirerbasic.xls
LIWC (Lingustic Inquiry and Word Count)
http://www.liwc.net
MPQA Subjectivity Cues Lexicon
Home page: http://www.cs.pitt.edy/mpqa/subj_lexicon.html
Bing Liu Opinion Lexicon
http://www.cs.uic.edu/~liub/FBS/opinion-lexicon-English.rar
SentiWordNet
Home page: http://sentiwordnet.isti.cnr.it
Analyzing the polarity of each word in IMDB (Christopher Potts)
How likely is each word to appear in each sentiment class?
Count (“bad”) in 1-star, 2-star, 3-star, etc.
But can’t use raw counts, instead likelihood.
Make them comparable between words, scaled likelihood.
Other sentiment feature: Logical negation
Is logical negation (no, not, never) associated with negative sentiment?
Potts’ experiment: Count negation in online reviews, regress against the review rating.
Potts 2011 results: More negation in negative sentiment.
Learning sentiment lexicons
Semi-supervised learning of lexicons
Use a small amount of information
-a few labeled examples
-a few hand-built patterns
To bootstrap a lexicon
Hatzivassiloglou and McKeown intuition for identifying word polarity
Adjectives conjoined by “and” have same polarity
-fair and legitimate, corrupt and brutal
Adjectives conjoined by “but” do not
-fair but brutal
Hatzivassiloglou and McKeown 1997
Step 1
Label seed set of 1336 adjectives
657 positive, 679 negative
Step 2
Expand seed set to conjoined adjectives
Google “was nice and”
what do we see:
nice, helpful
nice, classy
Step 3
Supervised classifier assigns “polarity similarity” to each word pair, resulting in a graph
Step 4
Clustering for partitioning the graph into two
Output polarity lexicon
positive words/negative words
Turney algorithm
1. Extract a phrasal lexicon from reviews.
2. Learn polarity of each phrase.
2. Rate a review by the average polarity of its phrases.
Extract two-word phrases with adjectives
How to measure polarity of a phrase?
Positive phrases co-occur more with “excellent”.
Negative phrases co-occur more with “poor”.
But how to measure co-occurrence?
Pointwoise mutual information
Mutual information between 2 random variables X and Y
Pointwise mutual information: How much more do events x and y co-occur than if they were independent?
PMI between two words: How much more do two words co-occur than if they were independent?
How to estimate pointwise mutual information
Query search engine (Altavista)
Does phrase appear more with “poor” or “excellent”?
Polarity(phrase)=PMI(phrase, “excellent”)-PMI(phrase, “poor”)
Results of Turney algorithm
-majority class baseline: 59%, Turney algorithm: 74%
-phrases rather than words
-learns domain-specific information
Using WordNet to learn polarity
-create positive and negative seed-words
-find synonyms and antonyms
-repeat, following chains of synonyms
-filter
Summary
Advantages
-can be domain-specific
-can be more robust (more words)
Intuition
-start with a seed set of words
-find other words that have similar polarity
Other sentiment tasks
Finding sentiment of a sentence
Important for finding aspects or attributes
-target of sentiment
Ex. “The food was great but the service was awful.”
positive sentiment about food, negative about service
Finding aspect/attribute/target of sentiment
Frequent phrases + rules
-find all highly frequent phrases across reviews (“fish tacos”)
-filter by rules like “occurs right after sentiment word”
-”…great fish tacos” means fish tacos a likely aspect
casino: casino, buffet, pool, resort, beds
children’s barber: haircut, job, experience, kids
department store: selection, department, sales, shop, clothing
The aspect name may not be in the sentence. For restaurants/hotels, aspects are well-understood.
Supervised classification
Hand-label a small corpus of restaurant review sentences with aspect
-food, decor, service, value, NONE
Train a classifier to assign an aspect to a sentence
-”Given this sentence, is the aspect food, decor, service, value or NONE.”
Putting it all together: Finding sentiment for aspects
Reviews > Text Extractor > Sentences & Phrases > Sentiment Classifier > Sentences & Phrases > Aspect Extractor > Sentences & Phrases > Aggregator > Final Summary
Baseline methods assume classes have equal frequencies
If not balanced (common in the real world) we can’t use accuracies as an evaluation, need to use F-scores.
Severe imbalancing also can degrade classifier performance.
Two common solutions:
1. Resampling in training, random undersampling.
2. Cost-sensitive learning, penalize SVM more for misclassification of the rare thing.
How to deal with 7 stars?
1. Map to binary.
2. Use linear or ordinal regression or specialized models like metric labeling.
Summary on sentiment
Generally modeled as classification or regression task
-predict a binary or ordinal label
Features:
-negation is important
-using all words (in Naive Bayes) works well for some tasks
-finding subset of words may help in other tasks (hand-built polarity lexicons, use seeds and semi-supervised learning to induce lexicons)
Computational work on other affective states
Emotion:
Detecting annoyed callers to dialogue system
Detecting confused/frustrated versus confident students
Mood:
Finding tramatized or depressed writers
Interpersonal stances:
Detection of flirtation or friendliness in conversations
Personality traits:
Detection of extroverts
Detection of friendliness
Friendly speakers use collaborative conversational style
-laughter
-less use of negative emotional words
-more sympathy
-more agreement
-less hedges
