繁体   English   中英

R中的tm_map错误消息

[英]tm_map error message in R

我可以在R中创建一个语料库,但是当我尝试对其应用tm_map函数时,出现以下错误消息:

UseMethod(“ as.PlainTextDocument”,x)中的错误:没有适用于'as.PlainTextDocument'的适用方法应用于类“ c('PlainTextDocument','TextDocument','character')”的对象

到目前为止的代码是:

setwd("C:/…/Documents/TextMining")
webtextGoogle <- GoogleNewsSource("Greek shipping")
GreekShippingContent <- WebCorpus(GoogleNewsSource("Greek shipping"))
writeCorpus(GreekShippingContent, "C:/…/Documents/TextMining", filenames = paste(seq_along(GreekShippingContent), ".txt", sep=""))
GreekShippingContent0 <- Corpus(DirSource("C:/…/Documents/TextMining"), list(reader = readPlain))
GreekShippingContent2 <- tm_map(GreekShippingContent0, as.PlainTextDocument)

我已经查看了文档和相关上下文中的含义的解释,但是我不知道该怎么做(不是开发人员)。 任何人都可以更正代码吗? 我从榜样中学到了很多。 谢谢。

这是一个黑暗的镜头,因为您没有以最小的方式传达问题。 我建议使用代码标签而不是注释来更改您的问题。 这有效:

library(tm)

GreekShippingContent <- "The Greek administration is coming under increasing pressure over it foot-dragging regarding its meeting international convention deadlines, especially when it relies on classification societies as an Recognised Organisation (RO) on its behalf. " 
GreekShippingContent0 <-  Corpus(VectorSource(GreekShippingContent))
tm_map(GreekShippingContent0, PlainTextDocument)

您将不得不做一些腿部工作,并适应您的情况。

暂无
暂无

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

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