java - 使用 Java/R 接口进行文本挖掘
问题描述
我正在尝试使用 JRI 对我的文件进行文本挖掘,这是我第一次这样做。所以这是我的代码:
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)")));
但我得到null
的结果是,我认为 tm 库没有加载或其他东西,正如我之前所说,这是我第一次这样做。
解决方案
推荐阅读
- javascript - 使用本地存储站点隐藏模式不起作用
- json - 将 AWS 云形成模板内容转换为 java 对象
- python - 池中的 Seaborn/Matplotlib - X 服务器“:1”上的致命 IO 错误 11(资源暂时不可用)
- python - 如何创建一个允许用户输入的循环,直到它们在 Python 中是正确的
- html - 为什么“首选”通过标头交付 Content-Security-Policy?
- amazon-s3 - 将 spark DataFrame 写入 s3?
- javascript - 类属性更改时 Redux 重新加载状态
- scala - 线程“主”java.lang.NoSuchMethodError 中的异常:scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps
- c# - 如何使 ComboBox 列的编辑器元素保存用户选择的新值?
- libcurl - libcurl:获取通过 CURLOPT_SSL_VERIFYSTATUS 请求的 libcurl 的结果