* This project was done with P-AI, an on-campus AI club. I was the project manager, and also worked with Elena, John, Kelly, and Phoebe.
In this project, we trained a neural network for the task of emotional analysis and then set it loose on a collection of first-person coming-of-age texts to see if there was a clear emotional arc that was consistent throughout each story-line. We specifically select first-person narratives for this project as they come from the perspective of a single narrator, and can reflect the growth of the narrator over time more consistently.
When fed a specific sentence our paragraph, our neural network could return the emotional valence of the sentence (joy, fear, neutral, sadness, angry). We analyzed a corpus of modern American coming-of-age stories, including works such as Catcher in the Rye, Kite Runner, To Kill a Mockingbird, The Outsiders, Norwegian Wood, and a couple of others. We limited our corpus to be works from after the 1930s.
Our final network was a BERT Transformer trained on a mixture of datasets that included ISEAR, a mixture of emotional situations, Daily Dialog, a collection of dialogs with specific emotional valence, and Fairy Tales, which was a corpus of fairy tales with emotional tags for each sentence. To determine that this was the optimal mixture of data, we performed multiple training iterations with a multitude of other datasets and found that this was the best collection for analyzing works of literature. Literature oftentimes tends to be quite finicky, as we encounter issues of mixing different eras of English, varied authorial voices, and other odd stipulations that don’t come around in a lot of common NLP situations. It is very important to determine the dataset and model combination that will work best for the specific style of literature you seek to analyze, as well as the era of literature.
After iterating through a multitude of hyperparams, we ended up with a model with an 84% F1 score, which is quite solid for multi-class emotional analysis.

Upon feeding the texts of our corpus to our model, we got something back that was quite noisy. We were unable to fit a general trend over all texts, but the emotional analysis is able to reveal interesting events within the individual texts.

Though the peaks in our Catcher in the Rye emotions graph are jagged and noisy, we can map some fun events onto the high valence peaks. We notice a high peak in anger in Chapter 3, which corresponds to Holden ranting about everyone being phonies and his roommate being a loser. In Chapter 13, we notice a peak in joy, which corresponds to Holden having a nice and lovely chat with a hooker.

In To Kill a Mockingbird, we notice a peak in anger at Chapter 9, which corresponds to Scout being mocked extensively in class. His classmates find Atticus’ representation of a black man in a trial to be disgusting, and make bully and poke fun at him for this. We also note a sustained peak of anger in Chapter 17-19, which corresponds to the trial of Tom, a tense and pivotal moment in the work. Furthermore, we notice a peak in fear in Chapter 28, which corresponds to when Scout and Jem are followed home and attacked by Bob Ewell, and angry drunk.
We can also analyze the emotions associated with a specific character. This leads to some revealing results as well.
On the left, we have a graph corresponding to the emotional frequency over time in Kite Runner, while to the right, we have the same thing but with emotions associated with the character Hassan. This simply means we only analyze sentences that contain the word “Hassan” which is a rather non-fine-grain way of going about it, but oh well. In chapter 7 we notice an interesting double peak of joy and fear in the general graph, while in the Hassan graph, it is a peak of pure fear. In this chapter, Amir wins the kite-flying contest, representing the joy, while Hassan is also raped in this chapter, representing the fear. This manifests as dual joy-fear peaks in the general frequency, but is a pure peak of fear for Hassan.
Overall, we were unable to derive a general trend, as seen from the extremely varied graphs. Though coming-of-age stories do predominantly feature the growth and maturation of a character, it appears that this process happens quite differently throughout works, or does not manifest well when analyzed from a pure computational method. Furthermore, it cannot be expected that simplifying texts into simple emotional valences can reveal a general pattern, as much of the beauty of literature is encapsulated in the subtleties of how a character’s perception of the world changes over time. Pure manifestations of emotion may not capture this well. However, this emotional analysis tool does map to rather interesting individual events, and is a fun tool to run random things through.


Leave a comment