如何在 R 中使用 tidytext 包正确删除停用词?

问题描述 投票:0回答:1

我在

tidytext
包中使用停用词数据集删除停用词。我正在使用以下代码:
R

最终输出如下:

library(tidyverse) library(tidytext) library(dplyr) data(stop_words) example_words <- c("the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog","i'm","don’t","it’s","i’ve") filtered_words <- example_words[!example_words %in% stop_words$word] filtered_words

我们可以看到像“don't”“it's”“i've”这样的停用词仍然出现在过滤后的输出中。但这些停用词实际上出现在停用词数据集中,并且不会以某种方式被删除。那么谁能帮我弄清楚为什么它不删除停用词数据集中出现的一些词?

r nlp stop-words tidytext
1个回答
0
投票
> filtered_words [1] "quick" "brown" "fox" "jumps" "lazy" "dog" "don’t" "it’s" "i’ve"

'

创建于 2023-04-07 与 

reprex v2.0.2

© www.soinside.com 2019 - 2024. All rights reserved.