作者shihs (shih)
看板R_Language
标题[问题] 文字探勘的stopwords
时间Thu Jul 2 17:01:02 2015
[问题类型]:
程式谘询(我想用R 做某件事情,但是我不知道要怎麽用R 写出来)
[软体熟悉度]:
入门(写过其他程式,只是对语法不熟悉)
[问题叙述]:
我想要用R做text mining,但在stopwords这个步骤的时候出错
Error in UseMethod("tm_map", x) :
no applicable method for 'tm_map' applied to an object of class "list"
[程式范例]:
#读进一个档案
data = readLines("test/test.txt")
#进行中文断词
insertWords(toTrad(iconv(c("民进党"), "big5", "UTF-8"), rev=TRUE))#增加词汇
segment.options(isNameRecognition = TRUE)#增加人名辨识
#将文章分词
data.seg = segmentCN(data, nature=FALSE)
#stop words
myStopWords = toTrad(stopwordsCN())
data.seg= tm_map(data.seg, removeWords, myStopWords) #清除停用字符
----------->最後一步出现Error in UseMethod("tm_map", x) :
no applicable method for 'tm_map' applied to an object of class "list"
[环境叙述]:
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.218.5.190
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/R_Language/M.1435827664.A.77D.html
1F:推 Edster: 这是哪个library, 还有你知道R中的list和字串character 07/02 19:05
2F:→ Edster: 的差异应该就能了解那段英文的意思。 07/02 19:06
3F:推 penolove: unlist 应该就能解了 07/03 02:24
4F:→ shihs: 是tm这个library 07/08 14:30
5F:→ shihs: unlist还是无法...错误变成是"character" 07/08 14:31