Reputation: 1919
sample_text <- ' Ramesh is my frien. He is a very good man'
Now I need to extract all the Pronouns (PRP
or PRP$
) from my text
acqTag <- tagPOS(sample_text)
I get the following
$POStagged
[1] "Ramesh/NNP is/VBZ my/PRP$ frien/NN ./. He/PRP is/VBZ a/DT very/RB good/JJ man/NN"
$POStags
[1] "NNP" "VBZ" "PRP$" "NN" "." "PRP" "VBZ" "DT" "RB" "JJ" "NN"
Now How do I get ony pronouns from here ? PRP or PRP$
Upvotes: 0
Views: 464
Reputation: 10233
What, exactly, do you want as the output? This seems to give what I think you want:
library("stringr")
prp <- str_extract_all(acqTag$POStagged,"\\w+/PRP\\$?")
str_replace(unlist(prp), "/PRP\\$?", "")
#[1] "my" "He"
Upvotes: 1