Literary NLP: Sentiment Across Classic Novels

Literary NLP: Sentiment Across Classic Novels#

Mapping mood through eight public-domain novels

Sentiment, emotion, vocabulary, and character presence as the plot unfolds

Project Overview#

Do novels darken as they head for the ending, or do they brighten? This project treats classic fiction as a time series: each book is split into page-sized windows of text, then a different NLP technique is applied on each page to watch language and mood change from opening to close.

The corpus is eight well-known public-domain titles from Project Gutenberg — gothic horror, a redemption fable, a marriage plot, and a trip down a rabbit-hole — chosen so the trajectories have something to disagree about.

Lexicon methods (VADER and the NRC emotion lexicon) are used throughout. They are fast, fully reproducible in a Jupyter Book build, and good enough to compare relative arcs. They are not a substitute for a literary reading: irony, archaic diction, and free indirect style can fool a word list.

Project Structure#

Six notebooks, each applying one technique to the same eight books:

1. Corpus & Cleaning

Explore →

Gutenberg texts, boilerplate stripping, page windows, chapter splits

2. Sentiment Trajectories

Explore →

VADER compound scores vs progress — does the ending darken or brighten?

3. Emotion Lexicon

Explore →

NRC joy, fear, sadness, anger, trust, and anticipation through the plot

4. Term Frequency

Explore →

Keyword trajectories vs page, and TF–IDF distinctive vocabulary

5. Word Clouds

Explore →

Whole-book clouds and beginning / middle / end vocabulary shift

6. Character Presence

Explore →

Who is on the page as the story moves — mention rates vs progress

Key Questions#

  • Which titles become darker in the final third, and which recover?

  • Do emotion lexicons pick up gothic fear versus Austenite trust?

  • Which words are distinctive to each novel once stopwords are stripped?

  • Can character mention-rates reconstruct a plot without reading it?

Preview Figures#

Corpus size by novel

Smoothed sentiment vs progress

Word clouds for the eight novels

Dataset#

  • Source: Project Gutenberg plain-text ebooks

  • Titles: Dracula, Wuthering Heights, The Time Machine, Pride and Prejudice, Frankenstein, Alice’s Adventures in Wonderland, A Christmas Carol, The Picture of Dorian Gray

  • Unit of analysis: ~250-word page windows (a Gutenberg file has no printer pagination)

  • Bundled file: data/pages.csv — committed so CI does not fetch Gutenberg at build time

Technical Stack#

Python • NLTK (VADER) • NRCLex • scikit-learn (TF–IDF) • wordcloud • Plotly • pandas


Ready to explore?

Start with the corpus →