R包中的RWeka出错

时间:2016-06-14 16:54:12

标签: java r rweka

我已搜索过SO和其他任何地方,没有任何方法可以修复不受支持的major.minor版本51错误。我卸载了Java 8并安装了Java 7.没有运气。 谢谢您的帮助。 我在用:  R 3.3.1 Java 8.91 OSX,el capitan 库(NLP) 库(TM) 库(RWeka) 库(rJava) 库((RWekajars)) 库(平行) 选项(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)) 

2 个答案:

答案 0 :(得分: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了解更多信息

答案 1 :(得分:0)

我一直在努力解决同一个问题。我一直在使用Java 1.8,我读的很好。然而问题似乎是在R里面安装的rJava包中。一旦我从rforge.net安装使用以下行,一切正常。

install.packages("rJava","http://rforge.net/",type="source")