Sentiment Analysis of the Harry Potter Series Using a Lexicon-Based Approach
Md Habib Al Mamun, Pantea Keikhosrokiani, Moussa Pourya Asl, Nur Ain Nasuha Anuar, Nurfarah Hadira Abdul Hadi, Thasnim Humida
Abstract
The objective of this chapter is to conduct a sentiment analysis of the Harry Potter novel series written by British author J.K. Rowling. The text of the series is collected from GitHub as an R package provided by Bradley Boehmke. The chapter analyzed the text by R programming to explore dominant sentiments using a lexicon approach of natural language processing (NLP). The results revealed that Professor Slughorn scored the most positive sentiment among the main characters that have heroic qualities; Death Eaters had the most negative sentiment among the anti-hero characters; negative sentiment in the text around the anti-hero characters increased significantly, while the positive sentiment around the hero characters remained constant as the story progressed throughout the series; among the series of novels, The Deathly Hallows contained the most negative sentiment; among all the houses of Hogwarts School of Witchcraft and Wizardry, Hufflepuff had the most positive sentiment; and each book of the series appeared negative until the final chapter, which always ended with a positive sentiment.