title: Visualize Parse Tree Structure
body: <p>I would like to display the parsing (POS tagging) from <strong>openNLP</strong> as a tree structure visualization.  Below I provide the parse tree from <strong>openNLP</strong> but I can not plot as a visual tree common to <a href="http://www.nltk.org/book/ch08.html#ubiquitous-ambiguity" rel="nofollow noreferrer">Python's parsing</a>. </p>
  
  <pre><code>install.packages(
      "http://datacube.wu.ac.at/src/contrib/openNLPmodels.en_1.5-1.tar.gz",  
      repos=NULL, 
      type="source"
  )
  
  library(NLP)
  library(openNLP)
  
  x &lt;- 'Scroll bar does not work the best either.'
  s &lt;- as.String(x)
  
  ## Annotators
  sent_token_annotator &lt;- Maxent_Sent_Token_Annotator()
  word_token_annotator &lt;- Maxent_Word_Token_Annotator()
  parse_annotator &lt;- Parse_Annotator()
  
  a2 &lt;- annotate(s, list(sent_token_annotator, word_token_annotator))
  p &lt;- parse_annotator(s, a2)
  ptext &lt;- sapply(p$features, `[[`, "parse")
  ptext
  Tree_parse(ptext)
  
  ## &gt; ptext
  ## [1] "(TOP (S (NP (NNP Scroll) (NN bar)) (VP (VBZ does) (RB not) (VP (VB work) (NP (DT the) (JJS best)) (ADVP (RB either))))(. .)))"
  ## &gt; Tree_parse(ptext)
  ## (TOP
  ##   (S
  ##     (NP (NNP Scroll) (NN bar))
  ##     (VP (VBZ does) (RB not) (VP (VB work) (NP (DT the) (JJS best)) (ADVP (RB either))))
  ##     (. .)))
  </code></pre>
  
  <p>The tree structure should look similar to this:</p>
  
  <p><a href="https://i.stack.imgur.com/Njv6T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Njv6T.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to display this tree visualization? </p>
  
  <p>I found <a href="https://stackoverflow.com/a/33499140/1000343">this related tree viz</a> question for plotting numeric expressions that may be of use but that I could not generalize to sentence parse visualization.</p>