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