I want to extract adjectives and adverbs from a vector, is there any way to do this ?
input <- "It's a good phone"
Expected output : "good"
I want to extract adjectives and adverbs from a vector, is there any way to do this ?
input <- "It's a good phone"
Expected output : "good"
You can use 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"