Sentiment and emotion
Within the sentiments dataset, the lexicon nrc contains a dictionary of words and an emotion associated with that word. Emotions such as joy, trust, anticipation, and others are found within this dataset.
In the Russian tweet bot dataset you have been exploring, you have looked at tweets sent out by both a left- and a right-leaning tweet bot. Explore the contents of the tweets sent by the left-leaning (democratic) tweet bot by using the nrc lexicon. The left tweets, left, have been tokenized into words, with stop-words removed.
Deze oefening maakt deel uit van de cursus
Introduction to Natural Language Processing in R
Oefeninstructies
- Create a tibble of just the anticipation words from the
nrclexicon. - Create a tibble of just the joy words from the
nrclexicon. - Print the top
anticipationwords found inleft_tokens. - Print the top
joywords found inleft_tokens.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
left_tokens <- left %>%
unnest_tokens(output = "word", token = "words", input = content) %>%
anti_join(stop_words)
# Dictionaries
anticipation <- ___("nrc") %>%
___(sentiment == "anticipation")
joy <- ___("nrc") %>%
___(sentiment == "joy")
# Print top words for Anticipation and Joy
left_tokens %>%
___(anticipation, by = "word") %>%
___(word, sort = TRUE)
left_tokens %>%
___(joy, by = "word") %>%
___(word, sort = TRUE)