Sentiment Analysis in Sebastian Barry’s Novel A Long Long Way

by Joseph Ryan Glover

I’m kicking around ideas for my thesis in Irish literature and one avenue I explored was examining Sebastian Barry’s 2005 novel A Long Long Way using some techniques from the digital humanities. For those who may be unfamiliar the digital humanities is a new academic discipline that seeks to apply data analysis tools to traditional humanities disciplines, such as English literature, to see what they can see. There are a lot of different techniques that fall under the umbrella of the digital humanities but I’m interested in what’s known as a sentiment analysis which is a kind of quantitative text analysis that seeks to measure the emotional tenor of a text. Barry’s novel is about the experience of the Irish during world war one and though I read the book eight years ago the thing that has stuck with me is the emotional highs and lows that Barry sends his protagonist Willie Dunne through. People often say that something is an “emotional rollercoaster” but I’ve only ever felt that A Long Long Way really embodied that characterization.  In my mind, this makes the novel a perfect test case for sentiment analysis because if it works the way it is advertised, the computer should be able to identify the same emotional highs and lows I did as a human reader.

In sentiment analysis, there seems to be two different schools of thought. The first school takes a machine learning approach to train an algorithm to determine in sentiment on a corpus of documents (usually tweets) while the second approach takes a database of words with scored sentiment and then calculates the sentiment of a text based on these words. I took the second approach because I’m not sure what value is there is in having a machine guess about sentiment when it can simply be calculated.

Googling around the internet there are a variety of techniques and approaches to performing sentiment analysis. Matthew Jockers of the University of Nebraska-Lincoln is doing interesting working look at the emotional trajectories of novels and he has produced a lot of good R code that can be downloaded and played with. Jockers approach seems to be to parse the text of a novel, in sequence, and run it through a sentiment function that attaches positive or negative scores to words with “emotional valence”. Emotional valence is defined differently by different researches but Jocker uses the AFINN sentiment database in part of his research and this database contains a list of words scored between -5 and 5 based on how negatively or positively emotional they are. In practice, this means that profanities such as bastard or prick are given a -5 while adjectives such as breathtaking and superb are rated a 5. The database I downloaded contained nearly 2500 English words scored by emotional valence and I used the database to score Barry’s novel.

There are a lot of tutorials around the web about how to perform sentiment analysis in Python or R and I spent some time studying them and I concluded that most of these tutorials were doing more work than I thought necessary. Beyond the machine learning approach (which I rejected) even Jockers was doing some elaborate Fast Fourier Transform work to analysis his texts and this seemed excessive. After some research I decided that my approach would be dead simple:

  • I’d break the text into individual words
  • I would score each word using the AFINN database
  • I would calculate a 5000-word rolling sum of the word scores
  • I would plot that result and see if it said anything interest

The only strange bit in this approach is the 5000-word rolling sum. Using AFINN, words can only have a score between -5 and 5 and the reality is that the majority of Barry’s 93000+ words would be given a score of 0 since they aren’t in AFINN’s database. Plotting each word seemed like it would result in a meaningless series of squiggles around the axis. I reasoned that, if an author is trying to use emotional language to move the reader, they are likely going to be building across sentences, paragraphs and pages in a general emotional direction. For that reason it makes sense to sum a lot of the scores together to see if the emotional valence of the text is rising or falling.

The good part about taking a simple approach is that all of the work can be done in Excel. I had one worksheet with every word in the novel on its own row and I had a second worksheet with all the AFINN words and their scores. Then I used a VLOOKUP to assign a score to each of the novel’s words based on the AFINN score. This screenshot demonstrates how simple the setup is:

After that I calculated the 5000-word rolling sum (in column D) using just the SUM formula and then charted it using a standard Excel line chart.

Visually, the chart of the emotional valence of the novel confirms the rollercoaster feeling I had when I read it. To be fair, I reckon a lot of novels follow this kind of emotional back and forth, Jockers’ research certainly indicates that they do, but it’s nice to see that the computer can identify the fact that the text of novel is loaded with positive and negative emotion just as a human reader can. That alone seems like a victory.

A few things about the chart:

  • The horizontal axis is labelled “Narrative Time” and this is a term I took from Jockers. It’s the words of the novel, in order, from start to finish. Barry’s novel is 93486 words long so the horizontal axis can also be called word count. It helps find a position in the novel.
  • The title of the chart says “Mid-Point Rolling Sum”. It’s a mid-point because when I was calculating the rolling sum I decided not to sum the scores for the last 5000 words for a particular location in the novel but rather the last 2500 and the next 2500 that bracketed a location in the novel. The choice for midpoint is strictly based on interpreting the text. If I use the last 5000 words, all of the emotional text lies before the high or low point, i.e. the emotional scene that caused the peak or trough is coming to an end. If I use the midpoint then I’m right in the middle of the high or low emotional action. I prefer the later for pulling quotes.
  • While the novel has emotional highs and lows it spends a lot more time below the zero line than above it. I think this is to be expected for a novel about the butchery and madness of world war one.

In the chart above I highlighted several alternating peaks and troughs. Using the word number I was able to pull out some choice quotes from the novel at those locations.

Word 15021, Page 49 in the 2005 Penguin paperback edition of the novel.

Willie Dunne is the protagonist of the novel and he’s a world war one soldier in the trenches. This first low point is a scene where the German’s use poison gas for the first time against the allies.

He awoke to a yellow world. His first thought was that he was dead. It was the small hours of the morning and there were still torches and lights being used. Long lines of men were going back along the road, with weird faces, their right hand on the right shoulder of the man in front, about forty men in a chain sometimes. He thought horribly of the Revelation of St John and wondered if by chance and lack he had reached the unknown date of the end of the living world.

Word 21829, Page 71

Willie returns home on furlough and his sisters give him a bath and feed him cheese and bread. He also meets with his father who is very proud of him.

‘Annie, Annie!’ she called. ‘Annie will help us. Don’t you worry, Willie, we’ll get you clean all right.’

And she rolled up her black sleeves and went down the back stairs for the zinc tub that was stowed in its place under the lower landing. She nearly collided with Annie in the door.

‘Annie, dear, you will need to boil up some bathwater promptly and we will be washing Willie Dunne immediately.’

‘Willie, Willie,’ said Annie. She rushed forward and was about to put her arms around him.

‘Don’t touch me, Annie, I’m all lousy and God knows what.’

‘Well, we had better clean you off before Dolly gets back from school, because you won’t be able to hold her off!’

Word 34879, Page 114

Willie, in the trenches, kills a German soldier in hand-to-hand combat as he watches his fellow soldiers fall to the poison of an exploded gas shell. The dead German will stay in Willie’s thoughts for the rest of his life.

A grey monster in a mask came leaping into their trench. He looked enormous. Whether he was or not Willie did not know, but he looked as big as a horse. He stood over Willie and all Willie could think of were Vikings, wild Vikings sacking an Irish town. It must have been a picture from a school book. He had never seen a German soldier before so close up. Once he saw three dejected German prisoners, poor maggots of men with heads bowed, being escorted to some prison camp through the reserve area. They had looked so sad and small no one even thought to mock them. They engendered silence to see them. But this man was not like them. He put his two hands on Willie’s shoulders and for a moment Willie thought he was going to rip off the gas mask and instinctively he put his hands up to hold it on. For some reason, without himself actually registering it, he had got the funny tomahawk into his left hand and when he raised the hand the spike at the top of the short stick horribly drove into the underchin of the German.

Word 39879, Page 129 

Willie and his unit take baths in an abandoned bathhouse that has miraculously survived bombing and shelling. They luxuriate in the baths, the camaraderie and in the singing of one of their fellows

The soldier struck his first note and passionately gave a ballad from the days of the Crimea. It was very lonesome, tender, and bloody. There was a young girl in it, and a soldier, and a death. The listeners were stilled because in the song there was a melody that brought from their own memories coloured hints and living sparks of the past. The past was a valued thing but it was also dangerous to them in the toxic wastelands of the war. It needed a box of safety round it, and this small room for concerts was as good as they had found.

Word 53486, Page 167 

Willie has assaulted a fellow soldier (and friend) who is retelling a story of a rape in which the soldier participated.

“All right, all right.’ But he didn’t seem able to say it for another few moments yet. Then he nodded his punched face. ‘She died of what had happened to her. She was bleeding all those hours. She was not treated right. She was fucking torn to pieces, wasn’t she? And she died. And we tried to save her.’

‘You think so?’

‘It’s just a story, Willie, a story of the war.’

‘You can keep your story, Pete. You can keep it.’

And Willie lay back trembling on his bed.

Word 61932, Page 194

Willie attends a boxing event put on for the soldiers. The fight is violent but well received by the male audience; a cathartic, atavistic event.

Now the bell went again and it seemed Miko Cuddy was in a fever to finish the fight, no doubt at the prompting of his seconds — the very same name as the men in an old-fashioned duel, Father Buckley noted — who had probably measured the big Ulsterman with mental measuring tape and had fearfully taken in the long reach and the thick muscle of the arms.

So Miko Cuddy came forth like a veritable whirligig, like a windmill on the flat white plain of the ring, whirling, whirling his arms, and before he could do much damage, William Beatty came at him like a ballet dancer, side-stepping and jigging and bouncing and finessing every punch, like a man inspired by the very poetry and possibility of movement, and curled in another punch to the very same ear he had caught in the first moment of the fight, and Willie Dunne swore afterwards that he seemed to feel that very punch himself on his own ear, and O’Hara did point out that in his excitement he had indeed landed a gentle box there, but only a shadow of the real thing.

Word 74001, Page 232

Willie and some soldiers are discussing what it means to be a victor in a war like world war one. They conclude that there is no meaningful definition for the word in their conflict.

‘ They might be calling that a sort of victory, i’n’t that it?’

‘Some fucking victory,’ said Willie Dunne.

‘Some fucking war,’ said Timmy Weekes.

‘And so say all of us,’ said Willie Dunne.

And that was strong talk. And that was all right for a while. But as that strange silence that could descend on you, even among your companions, descended on Willie Dunne, all ease and that tincture of happiness like the sweet juice in an orange left his brain. It began to throb with that all too familiar throbbing. A dash of grog might take that away. An ill thought, a curse, or a good sleep might also.

Word 81416, Page 253

Willie is visiting the family of the deceased Captain Pasley, a man he respected. It is a peak in the emotional valence but it is not above zero. It is solemn and resigned.

‘Ah yes,’ said the rector, and Willie by old experience knew how the rector’s brain was whirring, registering the name that would be unlikely to be a Protestant one, though the first name maybe betokened a certain deference to the powers that be. But, to give the man his due, his tone didn’t alter. His own name was written in gold lettering just behind him as it happened, on the black notice that said the name of the church and the rector-in-charge. ‘Well, my friend, you will find them at the top of the hill. I’ll bid you good day and God bless you.’

‘Thank you, Rector.’

‘Thank you, William, for taking the time to talk to me.’

Willie felt curiously heartened by the words of the rector. In fact, he was close to weeping as he trod on up to the house among the trees.

Word 87716, Page 275

The Catholic Irish were promised Home Rule by the British, after the war. Many young men volunteered for this reason. The 16th Division, comprised mostly of Irish is confirmed as nearly wiped out in this section. What they died for would not be honoured.

There was no point saying anything about it. Something had come to an end before even the war was over. Poor Father Buckley. The aspirations of poor men were annulled for ever. Any fella that had come out in the expectation of Home Rule could rest assured his efforts and his sacrifice were useless. For all that his father would think of it, Willie thought that was very sad. Very fucking sad. And very mysterious.

What is fascinating about most of these passages is that they don’t themselves contain a lot of emotional language but they are representative of very emotional scenes in the novel. The sorrow that haunts the novel, especially the second half, is very delicate and while it can be felt by an attuned reader it can also, seemingly, be detected by the computer. Over spans of thousands of words Barry is able to change the emotional drift of his novel through word selection without beating the reader over the head with it and for that reason I think this kind of analysis is useful. If nothing else it makes me appreciate, even more, Barry’s story-telling craftsmanship.