2013-12-20 47 views
2

我可以創建中的R語料庫,但是當我嘗試應用tm_map功能它,我收到以下錯誤信息:tm_map錯誤信息

錯誤UseMethod(「as.PlainTextDocument」,X): 應用於類 「C( 'PlainTextDocument', 'TextDocument', '字符')」 的對象關於 'as.PlainTextDocument' 不適用方法

到該點的代碼最多是:

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) 

我已經查閱了相關文章中的相關文檔和解釋xts,但我不明白該做什麼(不是開發人員)。任何人都可以糾正代碼?我通過例子學到了很多東西。謝謝。

+0

順便說一句我正在使用軟件包tm和tm.plugin.webmining。 – Dennis

+0

你還沒有給我們一個最簡單的例子,所以幫助很難。提供沒有數據的幫助就像修理你的汽車而不看車的機械師。即使他有一個理論,他也不能在沒有數據的情況下真正地檢驗理論。我的理論......嘗試'lapply(GreekShippingContent0,as.PlainTextDocument)',但這只是一個猜測。 –

+0

嗨泰勒,並感謝您的答案,我會盡快嘗試。由於我對這種板很陌生,你是否想要包含「內聯」數據,以便代碼能夠按照規定工作?我提供的代碼從Google下載 - 但如果在stackoverflow中的實踐是有內聯數據,我將在未來完成。這是你提供工作代碼的意思嗎?謝謝(並抱歉沒有按預期做到:-)) – Dennis

回答

4

這是在黑暗中拍攝的照片,因爲您尚未以最簡單的方式傳達問題。我建議用代碼標籤而不是評論來更改你的問題。這工作:

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) 

你必須做一些腿部工作,適用於你的情況。

+0

謝謝。到達那裏。享受假期。 – Dennis