簡體   English   中英

anti_join 無法識別我的數據集中的 tidytext 停用詞

[英]anti_join is not recognizing tidytext stop words in my dataset

我正在使用 R 中的 tidytext 方法從正文中刪除停用詞。 https://www.tidytextmining.com/tidytext.html

以下示例有效:

library(tidytext)
library(dplyr)

data(stop_words)
str_v <- paste(c("i've been dancing after midnight, i'd know because it's 
daylight"))

str_v %>% 
as_tibble %>% 
unnest_tokens(word, value) %>%
anti_join(stop_words)

當我將此方法應用於我正在使用的數據時,它不會出錯,但不會刪除停用詞。 為了匹配停用詞,文本結構是否需要發生一些不可見的事情? output 行看起來與停用詞相同(降低、壓扁等),但它們仍然存在……我正在處理受保護的數據,無法共享源材料。 關於這個問題的任何建議或建議都會非常有幫助,謝謝!

在與語法斗爭之后,問題是標點符號的偽影,總結為:

"’" != "'"

在向量中使用mutate()str_replace_all() ,現在停止詞工作。

answer <- 
 my_data %>% 
  mutate(text = str_replace_all(text, "’", "'"))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM