# NOT RUN {
mytext <- c(
"I am not afraid of you",
NA,
"",
"I love it [not really]",
"I'm not angry with you",
"I hate it when you lie to me. It's so humiliating",
"I'm not happpy anymore. It's time to end it",
"She's a darn good friend to me",
"I went to the terrible store",
"There is hate and love in each of us",
"I'm no longer angry! I'm really experiencing peace but not true joy.",
paste("Out of the night that covers me, Black as the Pit from pole to",
"pole, I thank whatever gods may be For my unconquerable soul."
),
paste("In the fell clutch of circumstance I have not winced nor cried",
"aloud. Under the bludgeonings of chance My head is bloody, but unbowed."
),
paste("Beyond this place of wrath and tears Looms but the Horror of the",
"shade, And yet the menace of the years Finds, and shall find, me unafraid."
),
paste("It matters not how strait the gate, How charged with punishments",
"the scroll, I am the master of my fate: I am the captain of my soul."
)
)
## works on a character vector but not the preferred method avoiding the
## repeated cost of doing sentence boundary disambiguation every time
## `emotion` is run
emotion(mytext)
## preferred method avoiding paying the cost
split_text <- get_sentences(mytext)
(emo <- emotion(split_text))
emotion(split_text, drop.unused.emotions = TRUE)
# }
# NOT RUN {
plot(emo)
plot(emo, drop.unused.emotions = FALSE)
plot(emo, facet = FALSE)
plot(emo, facet = 'negated')
library(data.table)
fear <- emo[
emotion_type == 'fear', ][,
text := unlist(split_text)][]
fear[emotion > 0,]
brady <- get_sentences(crowdflower_deflategate)
brady_emotion <- emotion(brady)
brady_emotion
# }
Run the code above in your browser using DataLab