替换文本中的表情符号

Replacing emojis in a text

我尝试用它们的意思替换表情符号。

Tweets$text[19]
"I ❤️ flying  . ☺️\U0001f44d"

对于这个任务,我使用 textclean 包。词典不仅包括表情符号描述,还包括字节码表示(x:列):

hash_emojis[1:3]
              x                        y
1: <e2><86><95>            up-down arrow
2: <e2><86><99>          down-left arrow
3: <e2><86><a9> right arrow curving left

所以结果是这样的:

Tweets$text[19] = replace_emoji(Tweets$text[19], emoji_dt = lexicon::hash_emojis)

Tweets$text[19]

 "I red heart <ef><b8><8f> flying . smiling face <ef><b8><8f> thumbs up "

我只想得到没有字节码表示的描述,因为我必须再次清理它。如何仅将 "y column" 应用于文本?他们可能是处理 R 中表情符号的更好方法吗?

使用replace_emoji后,可以使用replace_non_ascii去除ascii码

text <- "I ❤️ flying  . ☺️\U0001f44d"
t <- replace_emoji(text)
replace_non_ascii(t)
"I red heart flying . smiling face thumbs up"