Skip to content

Instantly share code, notes, and snippets.

@sudevschiz
Created August 22, 2018 08:02
Show Gist options
  • Save sudevschiz/c66cf06cdb3ec47c9af901f2af89cc89 to your computer and use it in GitHub Desktop.
Save sudevschiz/c66cf06cdb3ec47c9af901f2af89cc89 to your computer and use it in GitHub Desktop.
Sentiment analysis code
library(coreNLP)
library(qdap)
#Load the textData from csv
textData <- read.csv("comments.csv")
initCoreNLP(libLoc = "C:/Users/schirappat/Documents/R/win-library/3.3/coreNLP/extdata/stanford-corenlp-full-2016-10-31",mem = "8g", type = "english")
#Restart the machine if memory allocation error occurs
sentences <- qdap::sent_detect(textData[i])
#Find the sentiment of this sentence here itself
annotS <- coreNLP::annotateString(sentences)
#If getSentiment is not working, make sure that corenlp.propoerties has the "sentiment" annotator is present
sentiment <- coreNLP::getSentiment(annotS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment