1

我正在使用 R 3.3.0,由于某种原因,我无法在没有收到错误的情况下创建 DTM:

Error in UseMethod("meta", x) : 
  no applicable method for 'meta' applied to an object of class "try-error"
In addition: Warning messages:
1: In mclapply(x$content[i], function(d) tm_reduce(d, x$lazy$maps)) :
  all scheduled cores encountered errors in user code
2: In mclapply(unname(content(x)), termFreq, control) :
  all scheduled cores encountered errors in user code
The weird thing is, this error occurred only recently. I tried it before and it worked fine.

下面我粘贴了我使用的代码:

#pre-processing and transforming the corpus
myStopwords<- c(stopwords("english"), stopwords("SMART"))

my_corpus <- tm_map(corpus, content_transformer(tolower),lazy=TRUE)
my_corpus <- tm_map(my_corpus, removeWords, myStopwords, lazy=TRUE)
my_corpus <- tm_map(my_corpus, removeNumbers, lazy=TRUE)
my_corpus <- tm_map(my_corpus, removePunctuation, lazy=TRUE)
my_corpus <- tm_map(my_corpus, stripWhitespace, lazy=TRUE)
my_corpus <- tm_map(my_corpus, stemDocument, lazy=TRUE)
my_corpus <- tm_map(my_corpus, PlainTextDocument, lazy=TRUE)
my_corpus <- tm_map(my_corpus, content_transformer(function(x) iconv(x, to='UTF-8-MAC', sub='byte')), mc.cores=1, lazy=TRUE)

在阅读有关此错误的 stackoverflow 上的其他帖子后,我稍后添加了最后 2 行。但是,它仍然不起作用。

myDtm <- DocumentTermMatrix(
  my_corpus, control=list(
  wordLengths=c(3,Inf) 
)
)

会话信息()

R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] wordcloud_2.5      RColorBrewer_1.1-2 slam_0.1-35       
[4] SnowballC_0.5.1    tm_0.6-2           NLP_0.1-9         

loaded via a namespace (and not attached):
[1] parallel_3.3.0 tools_3.3.0    Rcpp_0.12.5   

我需要为我的硕士论文运行这个。我是 R 的初学者,我真的希望有人能帮助我!

4

0 回答 0