I am having an error in the following java method.   pipeline <- javaMethod('createCoreNLP', 'edu.stanford.nlp.pipeline.StanfordCoreNLP', 'en') Error in javaMethod("createCoreNLP", "edu.stanford.nlp.pipeline.StanfordCoreNLP", : could not find function "javaMethod"   Here is my codes: Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk-18.0.1.1') library(rJava) library(coreNLP) options( java.parameters = "-Xmx6g" ) #Set up the environment for Java #Init Java #.jinit(classpath = c(file.path(Sys.getenv('HOME'), '/Downloads/stanford-corenlp-full-2018-02-27/stanford-corenlp-3.9.1.jar'), file.path(Sys.getenv('HOME'), '/Downloads/stanford-corenlp-full-2018-02-27/slf4j-simple.jar'), file.path(Sys.getenv('HOME'), '/Downloads/stanford-corenlp-full-2018-02-27/slf4j-api.jar')), boundaries = '- Xmx5120m') .jinit(classpath = c(file.path(Sys.getenv('HOME'), '~/IS 688/stanford-corenlp-4.4.0/stanford-corenlp-4.4.0.jar'), file.path(Sys.getenv('HOME'), '~/IS 688/stanford-corenlp-4.4.0/slf4j-simple.jar'), file.path(Sys.getenv('HOME'), '~/IS 688/stanford-corenlp-4.4.0/ slf4j-api.jar')), boundaries = '- Xmx6g') #initCoreNLP("~/IS688/stanford-corenlp-4.4.0/",mem = "6g",parameterFile="~/IS688/stanford-corenlp-4.4.0/corenlp.properties") #Create thesentiment analyzer sentimentAnalyzer <- function(doc){    #Create an empty list sentimentList <- list()    #Create a CoreNLP pipeline pipeline <- javaMethod('createCoreNLP', 'edu.stanford.nlp.pipeline.StanfordCoreNLP', 'en')    #Annotate the document annotation <- javaMethod('process', 'edu.stanford.nlp.util.CoreMap', pipeline, doc)    #Get the sentiment of the first sentence sentiment <- javaMethod('get', 'edu.stanford.nlp.ling.CoreAnnotations$SentimentClass', annotation$get('sentences')[1])    #Add the sentiment to the list sentimentList$sentiment <- sentiment    #Get the tokens of the first sentence tokens <- javaMethod('get', 'edu.stanford.nlp.ling.CoreAnnotations$TokensAnnotation', annotation$get('sentences')[1])    #Add the tokens to the list sentimentList$tokens <- tokens    #Return the list return(sentimentList) }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 22SA
icon
Related questions
Question

I am having an error in the following java method.  

pipeline <- javaMethod('createCoreNLP', 'edu.stanford.nlp.pipeline.StanfordCoreNLP', 'en')

Error in javaMethod("createCoreNLP", "edu.stanford.nlp.pipeline.StanfordCoreNLP", :
could not find function "javaMethod"

 

Here is my codes:

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk-18.0.1.1')
library(rJava)

library(coreNLP)
options( java.parameters = "-Xmx6g" )


#Set up the environment for Java
#Init Java
#.jinit(classpath = c(file.path(Sys.getenv('HOME'), '/Downloads/stanford-corenlp-full-2018-02-27/stanford-corenlp-3.9.1.jar'), file.path(Sys.getenv('HOME'), '/Downloads/stanford-corenlp-full-2018-02-27/slf4j-simple.jar'), file.path(Sys.getenv('HOME'), '/Downloads/stanford-corenlp-full-2018-02-27/slf4j-api.jar')), boundaries = '- Xmx5120m')
.jinit(classpath = c(file.path(Sys.getenv('HOME'), '~/IS 688/stanford-corenlp-4.4.0/stanford-corenlp-4.4.0.jar'), file.path(Sys.getenv('HOME'), '~/IS 688/stanford-corenlp-4.4.0/slf4j-simple.jar'), file.path(Sys.getenv('HOME'), '~/IS 688/stanford-corenlp-4.4.0/ slf4j-api.jar')), boundaries = '- Xmx6g')


#initCoreNLP("~/IS688/stanford-corenlp-4.4.0/",mem = "6g",parameterFile="~/IS688/stanford-corenlp-4.4.0/corenlp.properties")


#Create thesentiment analyzer
sentimentAnalyzer <- function(doc){
  
#Create an empty list
sentimentList <- list()
  
#Create a CoreNLP pipeline
pipeline <- javaMethod('createCoreNLP', 'edu.stanford.nlp.pipeline.StanfordCoreNLP', 'en')
  
#Annotate the document
annotation <- javaMethod('process', 'edu.stanford.nlp.util.CoreMap', pipeline, doc)
  
#Get the sentiment of the first sentence
sentiment <- javaMethod('get', 'edu.stanford.nlp.ling.CoreAnnotations$SentimentClass', annotation$get('sentences')[1])
  
#Add the sentiment to the list
sentimentList$sentiment <- sentiment
  
#Get the tokens of the first sentence
tokens <- javaMethod('get', 'edu.stanford.nlp.ling.CoreAnnotations$TokensAnnotation', annotation$get('sentences')[1])
  
#Add the tokens to the list
sentimentList$tokens <- tokens
  
#Return the list
return(sentimentList)
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning