Understanding Sentiment Analysis Techniques
Understanding Sentiment Analysis Techniques
Mausam
(With slides from Jan Wiebe, Kavita Ganesan, Heng Ji, Dan Jurafsky, Chris Manning)
Motivation
“What people think?”
What others think has always been an important piece of information
Post Web
“…I don’t know who..but apparently it’s a good phone. It has good battery life and…”
• Blogs (google blogs, livejournal)
• E-commerce sites (amazon, ebay)
• Review sites (CNET, PC Magazine)
• Discussion forums ([Link],
[Link])
• Friends and Relatives (occasionally)
“Whoala! I have the reviews I need”
Now that I have “too much” information on one
topic…I could easily form my opinion and make
decisions…
Is this true?
…Not Quite
Searching for reviews may be difficult
Can you search for opinions as conveniently
as general Web search?
eg: is it easy to search for “iPhone vs Google Phone”?
“Let me look at reviews on one site only…”
Problems?
• Biased views
• all reviewers on one site may have the same opinion
• # of merchants
reviewed by the each of
these reviewers 1
Synonymous
&
Interchangeably Used!
So, what is Subjectivity?
• The linguistic expression of somebody’s opinions, sentiments,
emotions…..(private states)
Tech BLOG
-everything is plain text
Review on InfoWorld - -no separation between
tech news site CNET review positives and negatives
Example: iPhone review
Review posted on a tech blog
Review on InfoWorld -
tech news site CNET review
Subjectivity Analysis on iPhone Reviews
Individual’s Perspective
• Highlight of what is good and bad about iPhone
• Ex. Tech blog may contain mixture of information
• Combination of good and bad from the different sites (tech
blog, InfoWorld and CNET)
• Complementing information
• Contrasting opinions
Ex.
CNET: The iPhone lacks some basic features
Tech Blog: The iPhone has a complete set of features
Subjectivity Analysis on iPhone Reviews
Business’ Perspective
• Apple: What do consumers think about iPhone?
• Do they like it?
• What do they dislike?
• What are the major complaints?
• What features should we add?
• Apple’s competitor:
• What are iPhone’s weaknesses?
• How can we compete with them?
• Do people like everything about it?
Known as Business
Intelligence
15
•a
16
Bing Shopping
•a
Twitter sentiment versus Gallup Poll of
Consumer Confidence
Brendan O'Connor, Ramnath Balasubramanyan, Bryan R. Routledge, and Noah A. Smith. 2010. From
Tweets to Polls: Linking Text Sentiment to Public Opinion Time Series. In ICWSM-2010
18
Twitter sentiment:
Johan Bollen, Huina Mao, Xiaojun Zeng.
2011. Twitter mood predicts the stock
market,
Journal of Computational Science 2:1, 1-
8. 10.1016/[Link].2010.12.007.
19
• CALM predicts
Dow Jones
DJIA 3 days
later
• At least one
current hedge
fund uses this
CALM
algorithm
20
• Polarity detection:
• Is an IMDB movie review positive or negative?
• Data: Polarity Data 2.0:
• [Link]
IMDB data in the Pang and Lee database
✓ ✗
when _star wars_ came out some twenty years “ snake eyes ” is the most
ago , the image of traveling throughout the aggravating kind of movie : the kind
stars has become a commonplace image . […] that shows so much potential then
when han solo goes light speed , the stars becomes unbelievably disappointing .
change to bright lines , going towards the it’s not just because this is a brian
viewer in lines that converge at an invisible depalma film , and since he’s a great
point . director and one who’s films are
cool . always greeted with at least some
_october sky_ offers a much simpler image– fanfare .
that of a single white dot , traveling horizontally and it’s not even because this was a
across the night sky . [. . . ] film starring nicolas cage and since
he gives a brauvara performance ,
this film is hardly worth his talents .
Baseline Algorithm (adapted from Pang
and Lee)
• Tokenization
• Feature Extraction
• Classification using different classifiers
• Naïve Bayes
• MaxEnt
• SVM
35
vs
• I really like this movie
Determining Negation Scope and Strength in Sentiment Analysis, Hogenboom et al SMC 2011.
39
39
SMC 2011
40
41
42
count(w, c) +1
P̂(w | c) =
count(c) + V
43
• 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 Naïve Bayes
• Clips all the word counts in each document at 1
Boolean Multinomial Naïve Bayes:
Learning
• From training corpus, extract Vocabulary
• Calculate P(cj) terms • Calculate P(wk | cj) terms
j single doc containing all docsj
• For each cj in C do • Text
Remove duplicates in each doc:
docsj all docs with class =cj • For
• For eacheach word
word wktype w in docj
in Vocabulary
n• Retain
# of only a single instance
occurrences of w inofText
w
| docs j | k k j
P(c j ) ¬ nk + a
| total # documents| P(wk | c j ) ¬
n + a | Vocabulary |
45
48
49
CHALLENGES
• Ambiguous words
• This music cd is literal waste of time.
(negative)
• Please throw your waste material here.
(neutral)
• Sarcasm detection and handling
• “All the features you want - too bad they don’t
work. :-P”
• (Almost) No resources and tools for low/scarce resource
languages like Indian languages. 49
51
From: [Link]
52
Alternating Sentiment
I suggest that instead of fillings songs in tunes you should
fill tunes (not made of songs) only. The phone has good
popularity in old age people. Third i had tried much for its
data cable but i find it nowhere. It should be supplied with
set with some extra cost.
Good features of this phone are its cheapest price and
durability . It should have some features more than nokia
1200. it is easily available in market and repair is also
available
From: [Link]
53
Subject Centrality
• I have this personal experience of using this cell phone. I bought it one and half years back. It had
modern features that a normal cell phone has, and the look is excellent. I was very impressed by the
design. I bought it for Rs. 8000. It was a gift for someone. It worked fine for first one month, and then
started the series of multiple faults it has. First the speaker didnt work, I took it to the service centre
(which is like a govt. office with no work). It took 15 days to repair the handset, moreover they
charged me Rs. 500. Then after 15 days again the mike didnt work, then again same set of time
was consumed for the repairs and it continued. Later the camera didnt work, the speakes were
rubbish, it used to hang. It started restarting automatically. And the govt. office had staff which I
doubt have any knoledge of cell phones??
These multiple faults continued for as long as one year, when the warranty period ended. In this
period of time I spent a considerable amount on the petrol, a lot of time (as the service centre is a
govt. office). And at last the phone is still working, but now it works as a paper weight. The company
who produces such items must be sacked. I understand that it might be fault with one prticular
handset, but the company itself never bothered for replacement and I have never seen such
miserable cust service. For a comman man like me, Rs. 8000 is a big amount. And I spent almost
the same amount to get it work, if any has a good suggestion and can gude me how to sue such
companies, please guide.
For this the quality team is faulty, the cust service is really miserable and the worst condition of
any organisation I have ever seen is with the service centre for Fly and Sony Erricson, (it’s near
Sancheti hospital, Pune). I dont have any thing else to say.
From: [Link]
54
Thwarted Expectations
and Ordering Effects
Thwarted Expectations
and Ordering Effects
Riloff and Wiebe (2003). Learning extraction patterns for subjective expressions. EMNLP-2003.
• 6786 words
• 2006 positive
• 4783 negative
SentiWordNet
Stefano Baccianella, Andrea Esuli, and Fabrizio Sebastiani. 2010
SENTIWORDNET 3.0: An Enhanced Lexical Resource for Sentiment Analysis
and Opinion Mining. LREC-2010
62
63
POS good (883,417 tokens) amazing (103,509 tokens) great (648,110 tokens) awesome (47,142 tokens)
0.28 ●
0.27 ●
Scaled likelihood
Pr(c|w)
●
●
0.17 0.17 ●
0.16
●
●
P(w|c)/P(w)
● ●
0.12 ●
●
●
●
0.11 ●
0.1 ●
●
●
● ● ●
● ●
0.08 ●
● ●
●
●
●
●
● ● ●
●
0.05 ● ● ● ●
0.05 0.05 ● ● ●
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
Rating
NEG good (20,447 tokens) depress(ed/ing) (18,498 tokens) bad (368,273 tokens) terrible (55,492 tokens)
●
0.28
Scaled likelihood
0.21 ● ●
Pr(c|w)
●
0.16 ● ● ● ● 0.16
P(w|c)/P(w)
●
●
● 0.13 ● ●
0.12
0.1 0.11 ●
●
●
● ●
● ● ●
● ● ● ●
0.08 ●
●
●
● ●
●
0.03
●
● ● 0.04 ● ●
0.03
●
● ● ●
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
Rating
Other sentiment feature: Logical negation
Potts, Christopher. 2011. On the negativity of negation. SALT 20, 636-659.
a
Scaled likelihood
P(w|c)/P(w)
68
WordNet
71
WordNet
72
WordNet relations
73
WordNet relations
74
WordNet relations
75
WordNet glosses
93
94
95
nice, helpful
nice, classy
97
scenic nice
terrible
painful
handsome
fun
expensive
comfortable
98
+
slow
scenic
nice
terrible
handsome painful
fun
expensive
comfortable
101
Turney Algorithm
Turney (2002): Thumbs Up or Thumbs Down? Semantic Orientation Applied to Unsupervised
Classification of Reviews
P ( x, y )
PMI( x, y ) log 2
P( x) P( y )
• PMI between two words:
• How much more do two words co-occur than if they were independent?
P(word1,word2 )
PMI(word1, word2 ) = log2
P(word1)P(word2 )
How to Estimate Pointwise Mutual Information
• Query search engine (Altavista)
• P(word) estimated by hits(word)/N
• P(word1,word2) by hits(word1 NEAR word2)/N
• (More correctly the bigram denominator should be kN, because there are a
total of N consecutive bigrams (word1,word2), but kN bigrams that are k
words apart, but we just use N on the rest of this slide and the next.)
1
hits(word1 NEAR word2 )
PMI(word1, word2 ) = log N
2 1
N
hits(word1) N1 hits(word2 )
109
• Advantages:
• Can be domain-specific
• Can be more robust (more words)
• Intuition
• Start with a seed set of words (‘good’, ‘poor’)
• Find other words that have similar polarity:
• Using “and” and “but”
• Using words that occur nearby in the same document
• Using WordNet synonyms and antonyms
+/-
training
(:) words
1. Map to binary
2. Use linear or ordinal regression
• Or specialized models like metric labeling
Summary on Sentiment