TreeView extends View { public Tree<Constituent> getConstituentTree(int sentenceId) { if (sentenceId >= this.trees.size()) return null; Tree<String> sentence = getTree(sentenceId); Tree<Pair<String, IntPair>> labeledSpans = ParseUtils.getSpanLabeledTree(sentence); Constituent c = this.getRootConstituent(sentenceId); int offset = c.getStartSpan(); adjustTree(labeledSpans, offset); return getConstituentSubTree(labeledSpans); } TreeView(String viewName, TextAnnotation text);  TreeView(String viewName, String viewGenerator, TextAnnotation text, double score); static boolean isRoot(Constituent c); static boolean isLeaf(Constituent c); static Constituent getParent(Constituent constituent); Constituent getRootConstituent(int sentenceId); Constituent getRootConstituent(Sentence sentence); Tree<String> getTree(int sentenceId); Constituent getTreeRoot(int sentenceId); Constituent getTreeRoot(Sentence s); @Override String toString(); void setParseTree(int sentenceId, Tree<String> tree); void setDependencyTree(int sentenceId, Tree<Pair<String, Integer>> depTree); void setDependencyTree(int sentenceId, Tree<Pair<String, Integer>> depTree,
            double treeScore); void setScoredParseTree(int sentenceId, Tree<String> tree, Tree<Double> scores); Tree<Constituent> getConstituentTree(int sentenceId); @SuppressWarnings({"unchecked", "serial"}) Constituent getParsePhrase(Constituent c);  }
@Test public void testGetConstituentTree() throws Exception { Tree<Constituent> constituentTree = ((TreeView) ta.getView(ViewNames.PARSE_STANFORD)).getConstituentTree(0); Constituent root = constituentTree.getLabel(); assertEquals("S1", root.getLabel()); assertEquals(new IntPair(0, 11), root.getSpan()); Constituent firstNoun = constituentTree.getChild(0).getChild(0).getChild(0).getChild(1).getLabel(); assertEquals("construction", firstNoun.getSurfaceForm()); Constituent prepPhrase = constituentTree.getChild(0).getChild(1).getChild(1).getLabel(); assertEquals("on time", prepPhrase.getSurfaceForm()); assertEquals("IN", ta.getView(ViewNames.POS).getLabelsCovering(prepPhrase).get(0)); constituentTree = ((TreeView) ta.getView(ViewNames.PARSE_STANFORD)).getConstituentTree(1); }