Library ( tidyr ) get_sentiments ( "bing" ) #> # A tibble: 6,786 × 2 #> word sentiment #> #> 1 2-faces negative #> 2 abnormal negative #> 3 abolish negative #> 4 abominable negative #> 5 abominably negative #> 6 abominate negative #> 7 abomination negative #> 8 abort negative #> 9 aborted negative #> 10 aborts negative #> # ℹ 6,776 more rows janeaustensentiment % inner_join ( get_sentiments ( "bing" ), by = "word", relationship = "many-to-many" ) %>% count ( book, index = line %/% 80, sentiment ) %>% pivot_wider (names_from = sentiment, values_from = n, values_fill = 0 ) %>% mutate (sentiment = positive - negative ) janeaustensentiment #> # A tibble: 920 × 5 #> book index negative positive sentiment #> #> 1 Sense & Sensibility 0 16 32 16 #> 2 Sense & Sensibility 1 19 53 34 #> 3 Sense & Sensibility 2 12 31 19 #> 4 Sense & Sensibility 3 15 31 16 #> 5 Sense & Sensibility 4 16 34 18 #> 6 Sense & Sensibility 5 16 51 35 #> 7 Sense & Sensibility 6 24 40 16 #> 8 Sense & Sensibility 7 23 51 28 #> 9 Sense & Sensibility 8 30 40 10 #> 10 Sense & Sensibility 9 15 19 4 #> # ℹ 910 more rows
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |