/** * Set the parse tree of the {@code sentenceId}<sup>th</sup> sentence. * <p> * <b>Note</b>: The same TreeView cannot contain both the parse tree and the dependency tree and * will throw an exception if an attempt is made to set the parse tree in a view that has a * dependency tree. */ public void setParseTree(int sentenceId, Tree<String> tree) { safeInitializeTrees(); if (firstTree) { firstTree = false; this.isDependencyTree = false; } if (this.isDependencyTree) { throw new IllegalArgumentException("Not expecting a dependency tree, but found " + tree); } this.trees.set(sentenceId, tree); int sentenceStart = getSentenceStart(sentenceId); Tree<Pair<String, IntPair>> spanLabeledTree = ParseUtils.getSpanLabeledTree(tree); Pair<String, IntPair> rootLabel = spanLabeledTree.getLabel(); IntPair rootSpan = rootLabel.getSecond(); int rootStart = rootSpan.getFirst() + sentenceStart; int rootEnd = rootSpan.getSecond() + sentenceStart; Constituent root = createNewConstituent(rootStart, rootEnd, rootLabel.getFirst(), 1.0); this.addConstituent(root); addParseTree(spanLabeledTree, root, sentenceStart); }
/** * Set the parse tree of the {@code sentenceId}<sup>th</sup> sentence. * <p> * <b>Note</b>: The same TreeView cannot contain both the parse tree and the dependency tree and * will throw an exception if an attempt is made to set the parse tree in a view that has a * dependency tree. */ public void setParseTree(int sentenceId, Tree<String> tree) { safeInitializeTrees(); if (firstTree) { firstTree = false; this.isDependencyTree = false; } if (this.isDependencyTree) { throw new IllegalArgumentException("Not expecting a dependency tree, but found " + tree); } this.trees.set(sentenceId, tree); int sentenceStart = getSentenceStart(sentenceId); Tree<Pair<String, IntPair>> spanLabeledTree = ParseUtils.getSpanLabeledTree(tree); Pair<String, IntPair> rootLabel = spanLabeledTree.getLabel(); IntPair rootSpan = rootLabel.getSecond(); int rootStart = rootSpan.getFirst() + sentenceStart; int rootEnd = rootSpan.getSecond() + sentenceStart; Constituent root = createNewConstituent(rootStart, rootEnd, rootLabel.getFirst(), 1.0); this.addConstituent(root); addParseTree(spanLabeledTree, root, sentenceStart); }
this.addParseTree(child, childConstituent, sentenceStartPosition);
this.addParseTree(child, childConstituent, sentenceStartPosition);