我正在研究情绪,并想用R中的qdap用表达表情符号情绪的单词替换表情符号。
有人可以帮我怎么做。我将进一步使用输出来获取文本的整体情绪。
像这样的东西会起作用:
text <- "I like :) chicken but not beef :("
library(qdapDictionaries)
mgsub(as.character(emoticon[[2]]), as.character(emoticon[[1]]), text)
## "I like Smile chicken but not beef Sad"
如果我对您的理解正确并且您在谈论普通表情符号,则可以进行模式匹配并替换
R> text = c(":)", ":(")
R> gsub(":)", "happy", text)
[1] "happy" ":("