Cannot Initialize CoreNLP in R

自闭症网瘾萝莉.ら 提交于 2019-12-06 05:25:27

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.

Setup a particular version of java in RStudio

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!