Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2015 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/9ad5a294075e8880d967 to your computer and use it in GitHub Desktop.
Save anonymous/9ad5a294075e8880d967 to your computer and use it in GitHub Desktop.
playing with Jockers' Syuzhet package for R
#setwd(path-to-your-directoy)
install.packages("devtools")
devtools::install_github("mjockers/syuzhet")
library("syuzhet")
x <- get_text_as_string("text.csv")
text <- get_sentences(x)
# this gets sentiment by individual token
stext <- get_sentiment(text)
write.csv(stext, "stext.csv")
# this line scales your entire corpus, divides into tenths, plots sentiment over that
chunktext <- get_percentage_values(stext)
write.csv(chunktext, "chunktext.csv")
barplot(chunktext, main="this", xlab="that")
barplot(stext, main="this", xlab="that")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment