Sentiment analysis

"We shall nobly save, or meanly lose, the last, best hope of earth.” 
Abraham Lincoln

In this section, we'll take a look at the various sentiment options available in tidytext. Then, we'll apply that to a subset of the data before, during, and after the Civil War. To get started, let's explore the sentiments dataset that comes with tidytext:

> table(sentiments$lexicon)   AFINN bing loughran   nrc     2476 6788     4149 13901 

The four sentiment options and researchers associated with them are as follows:

  • AFINN: Finn, Arup, and Nielsen
  • bing: Bing, Liu et al.
  • loughran: Loughran and McDonald
  • nrc: Mohammad and Turney

The AFINN sentiment categorizes words on a negative to positive scale from -5 to +5. The bing version has a simple ...

Get Mastering Machine Learning with R - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.