title: How to use OpenNLP to get POS tags in R?
body: <p>Here is the R Code:</p>
  
  <pre><code>library(NLP) 
  library(openNLP)
  tagPOS &lt;-  function(x, ...) {
  s &lt;- as.String(x)
  word_token_annotator &lt;- Maxent_Word_Token_Annotator()
  a2 &lt;- Annotation(1L, "sentence", 1L, nchar(s))
  a2 &lt;- annotate(s, word_token_annotator, a2)
  a3 &lt;- annotate(s, Maxent_POS_Tag_Annotator(), a2)
  a3w &lt;- a3[a3$type == "word"]
  POStags &lt;- unlist(lapply(a3w$features, `[[`, "POS"))
  POStagged &lt;- paste(sprintf("%s/%s", s[a3w], POStags), collapse = " ")
  list(POStagged = POStagged, POStags = POStags)}
  str &lt;- "this is a the first sentence."
  tagged_str &lt;-  tagPOS(str)
  </code></pre>
  
  <p>Output is :</p>
  
  <blockquote>
    <p>tagged_str
        $POStagged
        [1]"this/DT is/VBZ a/DT the/DT first/JJ sentence/NN ./."</p>
  </blockquote>
  
  <p>Now I want to extract only NN word i.e sentence from the above sentence and want to store it into a variable .Can anyone help me out with this .</p>