Last active
September 23, 2016 13:23
-
-
Save deldersveld/5386bb905d89c9264349745cea50dcd1 to your computer and use it in GitHub Desktop.
R script that compares sentence/phrase sentiment using various lexicons from the Syuzhet package. Script is geared toward Microsoft Power BI with the "dataset" data frame, but it can easily be adapted for any data frame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bing.sentiment <- syuzhet::get_sentiment(as.vector(dataset$Text), method="bing") | |
afinn.sentiment <- syuzhet::get_sentiment(as.vector(dataset$Text), method="afinn") | |
nrc.sentiment <- syuzhet::get_sentiment(as.vector(dataset$Text), method="nrc") | |
raw <- cbind(bing.sentiment, afinn.sentiment, nrc.sentiment) | |
scaled <- scale(raw, center=TRUE) | |
colnames(scaled) <- c("bing.scaled", "afinn.scaled", "nrc.scaled") | |
sentiment.output <- cbind(dataset, raw, scaled) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment