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

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

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: tools-1.5.2-incubating
    • Fix Version/s: None
    • Component/s: Parser
    • Labels:
      None
    • Environment:

      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

            • Assignee:
              Unassigned
              Reporter:
              ofertal Ofer Tal
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: