Reputation: 21
I can create a corpus in R but when I try to apply tm_map functions to it I get the following error message:
Error in UseMethod("as.PlainTextDocument", x) : no applicable method for 'as.PlainTextDocument' applied to an object of class "c('PlainTextDocument', 'TextDocument', 'character')"
The code up to that point is:
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)
I have looked in the documentation and explanations of what this means in related contexts but I cannot understand what to do (not a developer). Can anyone correct the code? I have learned a lot by example. Thanks.
Upvotes: 2
Views: 7626
Reputation: 110004
This is a shot in the dark because you haven't conveyed the problem in a minimal way. I'd suggest to make changes in your question with code tags rather than as comments. This works:
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)
You'll have to do some leg work and apply to your situation.
Upvotes: 4