Re: [问题] R程式 文字处理(同义字转换)

楼主: koai (可笑的自以为...)   2014-10-20 12:40:38
不知道这是不是你要做的事?
有兴趣的话, 可以试试看!
x <- c("still call happening","still call issue","occurence",
"since first downloaded ios 8 now",
"since first downloaded ios 802 now",
"since first downloaded ios 8.0.2 now")
txt1 <- c("happen","happening","issue","occurence")
txt2 <- c("ios8","ios 8","ios 802","ios 8.0.2")
for (k in 2:length(txt1)) { x[grep(txt1[k],x)] <- txt1[1] }
for (k in 2:length(txt2)) { x[grep(txt2[k],x)] <- txt2[1] }
x
※ 引述《sinkome (涛哥)》之铭言:
: [问题类型]:
: 程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
: [软件熟悉度]:
: 入门(写过其他程式,只是对语法不熟悉)
: [问题叙述]:
: 目前我有一份文字档在Corpus中
: > inspect(new_data)
: <<VCorpus (documents: 1, metadata (corpus/indexed): 0/0)>>
: [[1]]
: <<PlainTextDocument (metadata: 7)>>
: still call happening
: since first downloaded ios 8 now
: (上面文件内容是经过stripWhitespace、removePunctuation等步骤而已)
: 然后我想自己定义一个
: 出现(happening,issue,occurence)归类为 happen
: 出现(ios 8,ios 802, ios 8.0.2)归类为 ios8
: 因此当
: happening 会转换成 happen
: ios 8 (中间含有空白) 会转换成 ios8
: 我试过wordnet package Synonyms,
: 但是我只会查询同义字,不会抓出来转换,
: 而且我比较倾向自己定义同义字。
: 想很久都不知道该如何写?

Links booklink

Contact Us: admin [ a t ] ucptt.com