我想从向量中提取形容词和副词,有什么办法吗?
input <- "It's a good phone"
预期输出:"good"
答案 0 :(得分:3)
您可以使用 tidytext :
library(tidytext)
library(tidyverse)
unnest_tokens(tibble(txt="It's a good phone"),word, txt) %>%
left_join(parts_of_speech) %>%
filter(pos %in% c("Adjective","Adverb")) %>%
pull(word) %>%
unique
# [1] "good"