[問題] tm包中Corpus的空白清除

作者: samex4x4 (Same)   2016-08-27 19:42:05
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
新手(沒寫過程式,R 是我的第一次)
[問題敘述]:
我有30個用結巴斷詞後的txt檔,想要使用tm包做文字探勘
問題在我沒有辦法讓讀進來的檔案斷開成一個一個乾淨的詞
都會變成以下情況
http://imgur.com/fsHDCJY.jpg
輸入到tm包裡的Corpus之後無法清除空白
嘗試用過Rwordseg包裡的segmentCN和strsplit都不行
[程式範例]:
http://ideone.com/imbirW
[環境敘述]:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
[關鍵字]:
文字探勘 tm
作者: cywhale (cywhale)   2016-08-27 20:44:00
gsub("\\s", "", x) can replace spaceso, use strsplit(x,"\\s") not work?
作者: Edster (Edster)   2016-08-27 22:52:00
應該先問你檔案內的文字怎麼分割的。用空白分割就,scan(file, sep=" ")
作者: cywhale (cywhale)   2016-08-28 08:23:00
so the problem is TermDocumentMatrix, not "strsplit"?try ..(..,control = list(wordLengths = c(1, Inf)))?

Links booklink

Contact Us: admin [ a t ] ucptt.com