1

我已经搜索了 SO 和其他任何地方,但没有任何方法可以修复不受支持的 major.minor 版本 51 错误。我卸载了 Java 8 并安装了 Java 7。没有运气。谢谢您的帮助。我正在使用:R 3.3.1 Java 8.91 OSX,el capitan library(NLP) library(tm) library(RWeka) library(rJava) library((RWekajars)) library(parallel) options(mc.cores=1) 这里是导致错误的 R 代码:

trigram <- function(x){NGramTokenizer(x,control=Weka_control(min=3,max=3))}
tdm <- TermDocumentMatrix(corpus2,control=list(tokenize=trigram))

Here is the error I get.
 Error in .jnew(name) : 
  java.lang.UnsupportedClassVersionError: weka/core/tokenizers/NGramTokenizer : Unsupported major.minor version 51.0 
9 stop(structure(list(message = "java.lang.UnsupportedClassVersionError: weka/core/tokenizers/NGramTokenizer : Unsupported major.minor version 51.0", 
    call = .jnew(name), jobj = <S4 object of class structure("jobjRef", package = "rJava")>), .Names = c("message", 
"call", "jobj"), class = c("UnsupportedClassVersionError", "ClassFormatError", 
"LinkageError", "Error", "Throwable", "Object", "Exception",  ... 
8 .jnew(name) 
7 NGramTokenizer(x, control = Weka_control(min = 3, max = 3)) 
6 .tokenize(doc) 
5 FUN(X[[i]], ...) 
4 lapply(X = X, FUN = FUN, ...) 
3 mclapply(unname(content(x)), termFreq, control) 
2 TermDocumentMatrix.VCorpus(corpus2, control = list(tokenize = trigram)) 
1 TermDocumentMatrix(corpus2, control = list(tokenize = trigram)) 
4

2 回答 2

2

我也在使用NGramTokenizer(x, control = Weka_control(min = 3, max = 3))

它为我制造了错误。我遇到了这个标记器,它为我解决了这个问题。

TrigramTokenizer <-
  function(x)
    unlist(lapply(ngrams(words(x), 3), paste, collapse = " "), use.names = FALSE)

请参阅:https ://rpubs.com/hokumski/capstone-milestone-week2了解更多信息

于 2016-06-20T19:00:43.793 回答
0

我整个星期都在尝试解决同样的问题。我一直在使用我读过的 Java 1.8。但是,问题似乎出在 R 内部安装的 rJava 包中。一旦我使用以下行从 rforge.net 安装,一切正常。

install.packages("rJava","http://rforge.net/",type="source")
于 2016-06-18T16:33:26.713 回答