Mallet in R regex错误:java.lang.NoSuchMethodException:没有适合给定参数的方法

Mallet in R regex错误:java.lang.NoSuchMethodException:没有适合给定参数的方法,regex,r,rjava,topic-modeling,mallet,Regex,R,Rjava,Topic Modeling,Mallet,我一直在学习如何在R中使用mallet创建主题模型的教程。我的文本文件每行有一句话。它看起来像这样,大约有50个句子 Thank you again and have a good day :). This is an apple. This is awesome! LOL! i need 2. . . . 这是我的代码: Sys.setenv(NOAWT=TRUE) #setup the workspace # Set working directory dir<-"/Users/

我一直在学习如何在R中使用mallet创建主题模型的教程。我的文本文件每行有一句话。它看起来像这样,大约有50个句子

Thank you again and have a good day :).
This is an apple.
This is awesome!
LOL!
i need 2.
.
.
. 
这是我的代码:

Sys.setenv(NOAWT=TRUE)

#setup the workspace
# Set working directory
dir<-"/Users/jxn"
Dir <- "~/Desktop/Chat/malletR/text" # adjust to suit
require(mallet)
documents1 <- mallet.read.dir(Dir)
View(documents1)
stoplist1<-mallet.read.dir("~/Desktop/Chat/malletR/stoplists")
View(stoplist1)
**mallet.instances <- mallet.import(documents1$id, documents1$text, "~/Desktop/Chat/malletR/stoplists/en.txt", token.regexp ="\\p{L}[\\p{L}\\p{P}]+\\p{L}")**
根据软件包,功能应该是这样的:

mallet.instances <- mallet.import(documents$id, documents$text, "en.txt",
                    token.regexp = "\\p{L}[\\p{L}\\p{P}]+\\p{L}")

mallet.instances我怀疑问题出在你的文本文件上。我遇到了相同的错误,并使用
as.character()
函数解决了它,如下所示:


mallet.instances您确定已将id字段也转换为字符吗?很容易忽略这些建议,而将其作为一个整数

Also there is a typo in the code sample: the backslashes have to be escaped:
    token.regexp = "\\p{L}[\\p{L}\\p{P}]+\\p{L}"
This usually occurs because the html text editor eats up one backslash.

有同样的问题,但没有解决。不知道你有什么想法。
mallet.instances <- mallet.import(documents$id, documents$text, "en.txt",
                    token.regexp = "\\p{L}[\\p{L}\\p{P}]+\\p{L}")
Also there is a typo in the code sample: the backslashes have to be escaped:
    token.regexp = "\\p{L}[\\p{L}\\p{P}]+\\p{L}"
This usually occurs because the html text editor eats up one backslash.