-3

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"

moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
  • 3
    Please provide an example of what you have tried. – Sada93 Apr 01 '19 at 21:14
  • Wide open question here, but I'd recommend looking at NLP projects in R like [this one](https://rpubs.com/lmullen/nlp-chapter) or [this one](https://github.com/quanteda/spacyr) or other SO questions like [this one](https://stackoverflow.com/questions/4600612/extracting-nounnoun-or-adjnounnoun-from-text) – Forrest Apr 01 '19 at 21:17
  • I see no reason at all to close this question. @cody-gray can you elaborate ? The question is precise enough and has sample data and an expected output.`r` is often used for text mining and I don't see how a question on parts of speech is out of scope. – moodymudskipper Apr 02 '19 at 01:20

1 Answers1

4

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"
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167