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.
Este exercício faz parte do curso
Introduction to Natural Language Processing in R
Instruções do exercício
- Create a tibble of just the anticipation words from the
nrc
lexicon. - Create a tibble of just the joy words from the
nrc
lexicon. - Print the top
anticipation
words found inleft_tokens
. - Print the top
joy
words found inleft_tokens
.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
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)