[问题] 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