Sentiment Mining

By Emily Snyder



Sentiment mining is pretty much a fancy way to say emotion tracker; simple, right?
With sentiment mining, we can determine certain emotions within a text based on how frequent they’re used while also showing where in the text positive and negative emotions appear most; which is not so simple.

Sentiment mining is pretty cool but, you have to keep in mind that as of right now, there are only eight emotions that are recognizable with sentiment mining. To see how they determined whether an emotion is positive or negative, visit the NCR Word-Emotion Association Lexicon.

So the question is, how does R determine what kind of sentence to link to a certain emotion? And, what if different people see certain emotions as positive or negative? So although, sentiment mining does produce some pretty cool looking graphs, it still has a ways to go. As sentiment mining is brand new, it needs a lot of refinement. However, it did capture the emotional plot arc so it’s very accurate.

So let’s break it down: below are two graphs created using sentiment mining within R Studio.

*Bar Graph (with sadness being the most frequently used emotion)*

x-axis = how often the emotion shows up within the play
y-axis = most-ranked emotions within the play

*Cosine graph (range of positive and negative emotion within the play)*

x-axis = displays the amount of time in the narrative
y-axis = displays where in the novel there are positive or negative emotions.


Now how do you create such cool graphs, you ask? Well—like I mentioned before—we use R Studio. To start, you’re going to need to install the Syuzhet package(to learn more about this package and similar ones, visit Jocker’s Blog). From there, you’ll use the code below (Using your own text). 


So by now, you’ve probably hit a couple errors but you eventually got the code to work. You should have gotten graphs in this order:
Note: (Graph 1 is basically a noisier version of Graph 2)


Now, if you want to be even more of a badass, you can also compare two different texts to each other. I used Harry Potter and the Cursed Child and The Cuckoo’s Calling. (See code below)

code 1

code 2

Once you’ve run the code, you’ll get a cosine graph with two different lines. (Harry Potter and the Cursed Child is in blue and The Cuckoo’s Calling is in red.)
Possible use: where they cross and find scenes to analyze. For more information visit Jocker’s Blog.

Cuckoo and Cursed

And now we ask, why?

Okay so here’s the deal: the graphs are cool to look at but what do they really do? Well, the graphs show us “comparison between perceived emotional positive/negative points and the actual language” (Mary Mackoy). So, for example, The Cuckoo’s Calling starts off with a murder scene and in the graph above, it starts off in the negatives. In contrast, Harry Potter and the Cursed Child starts with Albus going to Hogwarts which is a relatively positive emotional valence on the graph.

Now, by comparing the same author with two different books, we can see that although JK Rowling’s writing does overlap in emotional valence at some points, she doesn’t use the same emotions in her books. (Which makes sense considering one is about magic and the other is about murder.)

Real World Uses:

  • Sentiment Mining could be used for movie reviews to get a sense if it’s getting overall positive or negative reviews. In relation, it can also be used to see how a book is perceived before and after the movie adaptation.
  • In a class setting, it could be used for well-known books that the students could run through sentiment mining and then write essay to say if they think it’s accurate or not.
  • We can also analyze tweets and whether there is an overall positive or negative feedback associated. For instance, a recent sentiment mining project analyzed the mood of Trump’s tweets. Visit this website for more information.

And for all you Potterheads:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

Up ↑

%d bloggers like this: