Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
tools-1.5.2-incubating
-
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);