Are popular songs today happier or sadder than they were 50 years ago? In recent years, the availability of large digital datasets online and the relative ease of processing them means that we can now give precise and informed answers to questions such as this. A straightforward way to measure the emotional content of a text is just to count how many emotion words are present. How many times are negative-emotion words – ‘pain’, ‘hate’ or ‘sorrow’ – used? How many times are words associated with positive emotions – ‘love’, ‘joy’ or ‘happy’ – used? As simple as it sounds, this method works pretty well, given certain conditions (eg, the longer the available text is, the better the estimate of mood). This is a possible technique for what is called ‘sentiment analysis’. Sentiment analysis is often applied to social media posts, or contemporary political messages, but it can also be applied to longer timescales, such as decades of newspaper articles or centuries of literary works.