从语料库中删除特定单词

Remove specific words from a corpus

在这个过程之后如何从 myDfm 语料库中删除特定的词?

dflemma <- 
  spacy_parse(structure(df2$term, names = df2$id), lemma = TRUE, pos = FALSE) %>% 
  group_by(id = sub("(.+)-(.+)", "\1", doc_id)) %>% 
  summarise(text = paste(lemma, collapse = " "))

myCorpus <- corpus(dflemma[["text"]], docnames = dflemma[["id"]])

mystopwords <- c("can")
myDfm <- myCorpus %>%
  tokens(remove_punct = TRUE, remove_numbers = TRUE, remove_symbols = TRUE)  %>%
  tokens_remove(pattern = c(stopwords(source = "smart"), mystopwords))  %>%
  dfm(verbose = FALSE)

你想要

dfm_remove(myDfm, pattern = words_to_remove)