Analysing the emotional content of text is also becoming easier. In recent years, researchers have built up significant databases of the emotions that a given word evokes. This is part of the new field of sentiment analysis in which common words are categorised as positive, negative or neutral and associated with one the eight fundamental emotions—joy, sadness, anger, fear, trust, disgust, surprise and anticipation.

Mohammad has created his emotion analyser by combining these two advances with a clear method for visualising the results. For example, in analysing Shakespeare’s comedy As You Like It, he can display the number of words associated with each emotion that appear in every 10,000 words. This gives a kind of emotional signature.

Comparing this to the emotional signature of Hamlet, one of Shakespeare’s tragedies, is revealing (see image above). “Observe how one can clearly see that Hamlet has more fear, sadness, disgust, and anger, and less joy, trust, and anticipation,” he says.

And this is just the beginning. He can analyse the way the emotional temperature changes throughout a story, how different authors use emotion and how the use of emotion changes from one writing genre to another.

And he can reveal how the emotions associated with certain nouns differ. “For example, what is the distribution of emotion words used in proximity to mentions of women, race, and homosexuals,” he asks.

By searching for the emotions associated with characters in a story, it becomes possible to automatically generate summaries of their emotional states.

Beyond that, once an entire corpus of work has been analysed in this way, it becomes possible to compare them in unprecedented depth and detail. For example, Mohammad has analysed all of the Brothers Grimm fairy tales and arranged them in order of negative word density. The darkest turns out to be a tale called Gambling Hansel.

And Mohammad has not only compared stories but entire genres. “We compare emotion words in fairy tales and novels, to show that fairy tales have a much wider range of emotion word densities than novels,” he says.

That looks to be a powerful new way to analyse literature. There’s clearly no shortage of data to mine when it comes to novels and other tales. And there’s gold in them thar hills.

Ref:arxiv.org/abs/1309.5909: From Once Upon a Time to Happily Ever After: Tracking Emotions in Novels and Fairy Tales