简体   繁体   English

在R中使用tm包进行预处理时出错

[英]Error in preprocessing with tm package in R

I am trying to do some preprocessing with tm package in R. I wrote the lines below: 我试图用R中的tm包进行一些预处理。我写了以下几行:

corpus <- Corpus(VectorSource(Data))
corpus <- tm_map(corpus , asPlain)
corpus <- tmMap(corpus , removeSignature)

As you can see, I tried both 'tm_map' and 'tmMap'. 如您所见,我尝试了'tm_map'和'tmMap'。 But I faced these errors each time: 但我每次都遇到这些错误:

Error in match.fun(FUN) : object 'asPlain' not found
Error: could not find function "tmMap"

Could you please help me to solve this error? 你能帮我解决一下这个错误吗?

The tm package changed the function calls and some of those methods are no longer available. tm包更改了函数调用,其中一些方法不再可用。

Here is some sample code with the new functions. 这是一些带有新功能的示例代码。

require(tm)
text_corpus <- VCorpus( DirSource("20ng_train/sci.electronics"))
corpus_clean <- tm_map(text_corpus, content_transformer(tolower))
corpus_clean <- tm_map(corpus_clean, removeNumbers) 
corpus_clean <- tm_map(corpus_clean, removeWords, stopwords()) 
corpus_clean <- tm_map(corpus_clean, removePunctuation)
corpus_clean <- tm_map(corpus_clean, stemDocument)
corpus_clean <- tm_map(corpus_clean, stripWhitespace)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM