Skip to content

Instantly share code, notes, and snippets.

@shawngraham
Forked from anonymous/working-w-syuzhet.R
Created March 23, 2015 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawngraham/87bb74b576395737fc76 to your computer and use it in GitHub Desktop.
Save shawngraham/87bb74b576395737fc76 to your computer and use it in GitHub Desktop.
#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