2.2 Sentiment analysis with inner join

Because we name the count column word in unnest_tokens(), it’s convenient to join with the sentiment dataset:

Next, we count up how many positive and negative words there are in defined sections of each book. We define an index here to keep track of where we are in the narrative; this index (using integer division) counts up sections of 80 lines of text.