2024-02-2024
pp_book <- austen_books() %>%
filter(book == "Pride & Prejudice", text != "") %>%
mutate(chapter =
cumsum(str_detect(text, regex("^chapter [\\divxlc]",
ignore_case = TRUE)))) %>%
ungroup() %>% unnest_tokens(word,text) %>%
anti_join(stop_words) %>%
select(book, chapter, word) %>% filter(chapter != 0)
afinn <- get_sentiments("afinn")
sent_pp_book <- inner_join(afinn, pp_book)
sent_by_chapter <- sent_pp_book %>% group_by(chapter) %>% summarise(mean = mean(value)) %>% mutate(book_unit = "chapter") %>% rename(unit_num = chapter)
Chapter 14 Summary: “Over dinner, Mr. Collins spends a great deal of time describing the woman who has helped him establish his career in the clergy, Lady Catherine de Bourgh. He glowingly describes the widow and her daughter, who is apparently rather sickly.”
Chapter 46 Summary: “When she returns to the inn where she is staying, Elizabeth finds two letters from Jane. They are filled with upsetting information. Lydia has run away from Brighton with Wickham, and they are both missing. Elizabeth is dumbfounded. Lydia’s reputation will be destroyed, along with the family’s.”