Text mining using Java/R interface

46 Views Asked by At

I'm trying to do text mining using JRI for my file, this is my first time doing it. So this is my code:

    Rengine rengine = new Rengine(new String[]{"--vanilla"}, false, null);
    // TODO Auto-generated method stub

    rengine.eval("library(\"tm\")");


    rengine.eval("filePath <- \"C:\\\\Users\\\\acer\\\\Desktop\\\\tp_ged\\\\doc1\\\\f1.txt\"");

    rengine.eval("text <- readLines(filePath)");

    rengine.eval("docs <- Corpus(VectorSource(text))");

     rengine.eval("docs <- tm_map(docs, content_transformer(tolower))");
     rengine.eval("docs <- tm_map(docs, removeNumbers)");
     rengine.eval("docs <- tm_map(docs, removeWords, stopwords(\"english\"))");
     rengine.eval("docs <- tm_map(docs, removePunctuation)");
     rengine.eval("docs <- tm_map(docs, stripWhitespace)");
     //String[] result = rengine.eval("docs<- Corpus(VectorSource(text))").asStringArray();
     System.out.println("---"+rengine.eval("inspect(docs)")));

but I'm getting null as a result, I think the tm library isn't loading or something, as I said before this is my first time doing this.

0

There are 0 best solutions below