【发布时间】:2021-08-07 02:29:40
【问题描述】:
我必须使用 R 对包含表情符号的文本片段进行主题建模。使用 replace_emoji() 和 replace_emoticon 函数让我分析它们,但结果存在问题。
红心 emoji 被翻译为“红心 ufef”。然后在分析过程中分别处理这些词并影响结果。
像“心”这样的词可以有非常不同的含义,就像“红心 ufef”和“破碎的心”一样
replace_emoji_identifier() 函数也无济于事,因为标识符使分析变得困难。
使用dput()可重现的虚拟数据集(包括步骤force to lowercase:
Emoji_struct <- c(
list(content = "???????? wow", "???? look at that", "????this makes me angry????", "????❤\ufe0f, i love it!"),
list(content = "????????", "???? thanks for helping", "???? oh no, why? ????", "careful, challenging ❌❌❌")
)
当前编码(data_orig是几个文件的列表):
library(textclean)
#The rest should be standard r packages for pre-processing
#pre-processing:
data <- gsub("'", "", data)
data <- replace_contraction(data)
data <- replace_emoji(data) # replace emoji with words
data <- replace_emoticon(data) # replace emoticon with words
data <- replace_hash(data, replacement = "")
data <- replace_word_elongation(data)
data <- gsub("[[:punct:]]", " ", data) #replace punctuation with space
data <- gsub("[[:cntrl:]]", " ", data)
data <- gsub("[[:digit:]]", "", data) #remove digits
data <- gsub("^[[:space:]]+", "", data) #remove whitespace at beginning of documents
data <- gsub("[[:space:]]+$", "", data) #remove whitespace at end of documents
data <- stripWhitespace(data)
期望的输出:
[1] list(content = c("fire fire wow",
"facewithopenmouth look at that",
"facewithsteamfromnose this makes me angry facewithsteamfromnose",
"smilingfacewithhearteyes redheart \ufe0f, i love it!"),
content = c("smilingfacewithhearteyes smilingfacewithhearteyes",
"smilingfacewithsmilingeyes thanks for helping",
"cryingface oh no, why? cryingface",
"careful, challenging crossmark crossmark crossmark"))
有什么想法吗?小写也可以。 最好的祝福。注意安全。保持健康。
【问题讨论】:
标签: r emoji topic-modeling data-preprocessing