title: Get parse tree of a sentence using OpenNLP. Getting stuck with example.
body: <p>OpenNLP is an Apache project on Natural Language Processing. One of the aims of an NLP program is to parse a sentence giving a tree of its grammatical structure. For example, the sentence "The sky is blue." might be parsed as</p>
  
  <pre><code>      S
       / \
     NP   VP
    / \    | \
  The sky is blue.
  </code></pre>
  
  <p>where <code>S</code> is Sentence, <code>NP</code> is Noun-phrase, and <code>VP</code> is Verb-phrase. Equivalently the above tree can be written down as a parenthesized string like this: <code>S(NP(The sky) VP(is blue.))</code></p>
  
  <p>I am trying to be able to get the parenthesized strings from sentences using OpenNLP, but I can't get the example code to work. </p>
  
  <p>In particular, I am following along <a href="http://www.programcreek.com/2012/05/opennlp-tutorial/#parser" rel="nofollow">the last part of this tutorial</a> and my code gets stuck at initializing <code>ParserModel</code>.</p>
  
  <p>I have downloaded the appropriate binaries from <a href="http://opennlp.apache.org/cgi-bin/download.cgi" rel="nofollow">here</a> and added <code>opennlp-tools-1.5.3.jar</code> (which includes classes for all of the following objects) as a library to my IntelliJ project. Also, I moved <code>en-parser-chunking.bin</code> to my "user.dir."</p>
  
  <p>The following is the code which should give me a parse tree, but it runs indefinitely at creating the <code>ParserModel</code> object. </p>
  
  <pre><code>    InputStream is = new FileInputStream("en-parser-chunking.bin");
      ParserModel model = new ParserModel(is);
      Parser parser = ParserFactory.create(model);
      String sentence = "The sky is blue.";
      Parse topParses[] = ParserTool.parseLine(sentence, parser, 1);
      for (Parse p : topParses)
          p.show();
      is.close();
  </code></pre>
  
  <p>It's my first day of working with OpenNLP, but I can't even get this simple example to work. </p>