/** * Makes the tree objects. This creates one tree per sentence. */ protected void makeTrees() { safeInitializeTrees(); for (int sentenceId = 0; sentenceId < this.getTextAnnotation().getNumberOfSentences(); sentenceId++) { Constituent root = this.getRootConstituent(sentenceId); if (root == null) { // throw new IllegalStateException( // "Unable to find the root constituent. " // + "Maybe the view is not restricted to a single sentence."); trees.set(sentenceId, null); } else trees.set(sentenceId, makeTree(root)); } firstTree = false; }
/** * Makes the tree objects. This creates one tree per sentence. */ protected void makeTrees() { safeInitializeTrees(); for (int sentenceId = 0; sentenceId < this.getTextAnnotation().getNumberOfSentences(); sentenceId++) { Constituent root = this.getRootConstituent(sentenceId); if (root == null) { // throw new IllegalStateException( // "Unable to find the root constituent. " // + "Maybe the view is not restricted to a single sentence."); trees.set(sentenceId, null); } else trees.set(sentenceId, makeTree(root)); } firstTree = false; }
/** * Get the constituents comprising the sentence at the provided index organized into a * tree. * @param sentenceId the id of the sentence. * @return a tree comprised of constituents. */ public Tree<Constituent> getConstituentTree(int sentenceId) { if (sentenceId >= this.trees.size()) return null; // first get the parse tree containing for each label the token offsets as a pair. Tree<String> sentence = getTree(sentenceId); // now get the span labeled tree Tree<Pair<String, IntPair>> labeledSpans = ParseUtils.getSpanLabeledTree(sentence); // the offset are relative to the beginning of the tree adjust to the start of text. // the root constituent will contain the starting location. Constituent c = this.getRootConstituent(sentenceId); int offset = c.getStartSpan(); // now adjust each of the tree pairs to the constituents offset. adjustTree(labeledSpans, offset); return getConstituentSubTree(labeledSpans); }
/** * Get the constituents comprising the sentence at the provided index organized into a * tree. * @param sentenceId the id of the sentence. * @return a tree comprised of constituents. */ public Tree<Constituent> getConstituentTree(int sentenceId) { if (sentenceId >= this.trees.size()) return null; // first get the parse tree containing for each label the token offsets as a pair. Tree<String> sentence = getTree(sentenceId); // now get the span labeled tree Tree<Pair<String, IntPair>> labeledSpans = ParseUtils.getSpanLabeledTree(sentence); // the offset are relative to the beginning of the tree adjust to the start of text. // the root constituent will contain the starting location. Constituent c = this.getRootConstituent(sentenceId); int offset = c.getStartSpan(); // now adjust each of the tree pairs to the constituents offset. adjustTree(labeledSpans, offset); return getConstituentSubTree(labeledSpans); }
if (parseTreeView.getTree(i) != null) { Constituent parseTreeRoot = parseTreeView.getRootConstituent(i); Tree<Pair<String, Integer>> labeledDependencyTree = depParser.getLabeledDependencyTree(parseTreeRoot);
if (parseTreeView.getTree(i) != null) { Constituent parseTreeRoot = parseTreeView.getRootConstituent(i); Tree<Pair<String, Integer>> labeledDependencyTree = depParser.getLabeledDependencyTree(parseTreeRoot);