[英]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.