Uploaded image for project: 'OpenNLP'
  1. OpenNLP
  2. OPENNLP-509

opennlp.tools.parser.Parse.getParent() returning incorrect object

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • tools-1.5.2-incubating
    • 2.2.0
    • Parser
    • None

    Description

      After parsing a sentence with opennlp.tools.parser.Parse.parse() some (many) Parse children do not have the correct parent set.

      Details:
      given a Parse node in the tree (let's assume it is in a variable named p)
      When iterating over the Parse[] returned by p.getChildren(), checking p.equals(children[i].getParent()) returns false in many, if not all of the nodes.

      More background –
      to create the parse tree, I used the code:

      opennlp.tools.parser.Parse p = new opennlp.tools.parser.Parse(parseSentence, new opennlp.tools.util.Span(0, parseSentence.Length), opennlp.tools.parser.AbstractBottomUpParser.INC_NODE, 1, null);
      
                  // create a parse object for each token and add it to the parent
                  int start = 0;
                  foreach (string token in tokenizedSentence)
                  {
                      {
                          opennlp.tools.parser.Parse tokenParse = new opennlp.tools.parser.Parse(parseSentence,
                                                                  new opennlp.tools.util.Span(start, start + token.Length),
                                                                  opennlp.tools.parser.AbstractBottomUpParser.TOK_NODE,
                                                                  0,
                                                                  0);                    
                          p.insert(tokenParse);
                          start += token.Length + 1;
                      }
                  }
      
                  // fetch 1 possible parse trees
                  opennlp.tools.parser.Parse[] parses = parser.parse(p, 1);
      

      Attachments

        Activity

          People

            mawiesne Martin Wiesner
            ofertal Ofer Tal
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: