Reputation: 1619
I am unable to access coreNLP
in R on a Mac running High Sierra. I am uncertain what the problem is, but it seems that every time I try again to get coreNLP
to work, I am faced with a different error. I have JDK 9.0.4. Please see my code below for what I am attempting to do, and the error that stops me.
My previous attempt I was able to get initCoreNLP()
to run and load some elements of the packages, but it would fail on others. When I then attempted to run annotateString()
, it would throw the error Error Must initialize with 'int CoreNLP'!
.
I have downloaded and re-downloaded the coreNLP
Java archive many times and still no luck! See image for contents of my coreNLP
R package folder located at /Library/Frameworks/R.framework/Versions/3.4/Resources/library/coreNLP
.
Do you know how I can successfully initialize coreNLP
?
dyn.load("/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/lib/server/libjvm.dylib")
library(NLP)
library(coreNLP)
> downloadCoreNLP()
trying URL 'http://nlp.stanford.edu/software//stanford-corenlp-full-2015-12-09.zip'
Content type 'application/zip' length 403157240 bytes (384.5 MB)
==================================================
downloaded 384.5 MB
> initCoreNLP()
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Searching for resource: StanfordCoreNLP.properties
Error in rJava::.jnew("edu.stanford.nlp.pipeline.StanfordCoreNLP", basename(path)) :
edu.stanford.nlp.io.RuntimeIOException: ERROR: cannot find properties file "StanfordCoreNLP.properties" in the classpath!
Upvotes: 2
Views: 1514
Reputation: 8676
Per our discussion.
My sense is your Java / R configuration dependency issue. Thus, it appears that rJava
is dependent on the version of java
used and coreNLP
is dependent on rJava
.
java <- rJava <- coreNLP
thus we can set the dlynlib version to 1.8.X, uninstall rJava, reinstall rJava then reinstall coreNLP.
dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
remove.packages("rJava")
install.packages("rJava")
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
# usage
packages <- c("NLP", "coreNLP", "rJava")
ipak(packages)
.jinit()
.jcall("java/lang/System","S","getProperty","java.version")
# run the follwoing command once
# downloadCoreNLP() # <- Takes a while...
initCoreNLP()
example(getSentiment)
sIn <- "Mother died today. Or, maybe, yesterday; I can't be sure."
annoObj <- annotateString(sIn)
Upvotes: 1