Created
August 22, 2018 08:02
-
-
Save sudevschiz/c66cf06cdb3ec47c9af901f2af89cc89 to your computer and use it in GitHub Desktop.
Sentiment analysis code
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
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