@Test public void testDepParser() throws Exception { DepAnnotator depParser = new DepAnnotator(); try { depParser.addView(ta); assertTrue(ta.hasView(ViewNames.DEPENDENCY)); TreeView depTree = (TreeView) ta.getView(ViewNames.DEPENDENCY); assertEquals("finished", depTree.getTreeRoot(0).getSurfaceForm()); } catch (AnnotatorException e) { e.printStackTrace(); fail(); } }
@Override public void addView(TextAnnotation ta) throws AnnotatorException { for (String reqView : requiredViews) if (!ta.hasView(reqView)) throw new AnnotatorException("TextAnnotation must have view: " + reqView); DepInst sent = new DepInst(ta); DepStruct deptree; try { deptree = (DepStruct) model.infSolver.getBestStructure(model.wv, sent); } catch (Exception e) { throw new AnnotatorException("Sentence cannot be parsed"); } TreeView treeView = new TreeView(ViewNames.DEPENDENCY, ta); int rootPos = findRoot(deptree); Pair<String, Integer> nodePair = new Pair<>(sent.forms[rootPos], rootPos - 1); Tree<Pair<String, Integer>> tree = new Tree<>(nodePair); populateChildren(tree, deptree, sent, rootPos); treeView.setDependencyTree(0, tree); ta.addView(ViewNames.DEPENDENCY, treeView); }
DepAnnotator extends Annotator { @Override public void addView(TextAnnotation ta) throws AnnotatorException { for (String reqView : requiredViews) if (!ta.hasView(reqView)) throw new AnnotatorException("TextAnnotation must have view: " + reqView); DepInst sent = new DepInst(ta); DepStruct deptree; try { deptree = (DepStruct) model.infSolver.getBestStructure(model.wv, sent); } catch (Exception e) { throw new AnnotatorException("Sentence cannot be parsed"); } TreeView treeView = new TreeView(ViewNames.DEPENDENCY, ta); int rootPos = findRoot(deptree); Pair<String, Integer> nodePair = new Pair<>(sent.forms[rootPos], rootPos - 1); Tree<Pair<String, Integer>> tree = new Tree<>(nodePair); populateChildren(tree, deptree, sent, rootPos); treeView.setDependencyTree(0, tree); ta.addView(ViewNames.DEPENDENCY, treeView); } }
DepAnnotator extends Annotator { @Override public void addView(TextAnnotation ta) throws AnnotatorException { for (String reqView : requiredViews) if (!ta.hasView(reqView)) throw new AnnotatorException("TextAnnotation must have view: " + reqView); DepInst sent = new DepInst(ta); DepStruct deptree; try { deptree = (DepStruct) model.infSolver.getBestStructure(model.wv, sent); } catch (Exception e) { throw new AnnotatorException("Sentence cannot be parsed"); } TreeView treeView = new TreeView(ViewNames.DEPENDENCY, ta); int rootPos = findRoot(deptree); Pair<String, Integer> nodePair = new Pair<>(sent.forms[rootPos], rootPos - 1); Tree<Pair<String, Integer>> tree = new Tree<>(nodePair); populateChildren(tree, deptree, sent, rootPos); treeView.setDependencyTree(0, tree); ta.addView(ViewNames.DEPENDENCY, treeView); } DepAnnotator();  DepAnnotator(boolean lazilyInitialize);  DepAnnotator(boolean lazilyInitialize, ResourceManager rm); }
DepAnnotator extends Annotator { @Override public void addView(TextAnnotation ta) throws AnnotatorException { for (String reqView : requiredViews) if (!ta.hasView(reqView)) throw new AnnotatorException("TextAnnotation must have view: " + reqView); DepInst sent = new DepInst(ta); DepStruct deptree; try { deptree = (DepStruct) model.infSolver.getBestStructure(model.wv, sent); } catch (Exception e) { throw new AnnotatorException("Sentence cannot be parsed"); } TreeView treeView = new TreeView(ViewNames.DEPENDENCY, ta); int rootPos = findRoot(deptree); Pair<String, Integer> nodePair = new Pair<>(sent.forms[rootPos], rootPos - 1); Tree<Pair<String, Integer>> tree = new Tree<>(nodePair); populateChildren(tree, deptree, sent, rootPos); treeView.setDependencyTree(0, tree); ta.addView(ViewNames.DEPENDENCY, treeView); } DepAnnotator();  DepAnnotator(boolean lazilyInitialize);  DepAnnotator(boolean lazilyInitialize, ResourceManager rm); @Override void initialize(ResourceManager rm); @Override void addView(TextAnnotation ta); }
DepAnnotator extends Annotator { @Override public void addView(TextAnnotation ta) throws AnnotatorException { for (String reqView : requiredViews) if (!ta.hasView(reqView)) throw new AnnotatorException("TextAnnotation must have view: " + reqView); DepInst sent = new DepInst(ta); DepStruct deptree; try { deptree = (DepStruct) model.infSolver.getBestStructure(model.wv, sent); } catch (Exception e) { throw new AnnotatorException("Sentence cannot be parsed"); } TreeView treeView = new TreeView(ViewNames.DEPENDENCY, ta); int rootPos = findRoot(deptree); Pair<String, Integer> nodePair = new Pair<>(sent.forms[rootPos], rootPos - 1); Tree<Pair<String, Integer>> tree = new Tree<>(nodePair); populateChildren(tree, deptree, sent, rootPos); treeView.setDependencyTree(0, tree); ta.addView(ViewNames.DEPENDENCY, treeView); } DepAnnotator();  DepAnnotator(boolean lazilyInitialize);  DepAnnotator(boolean lazilyInitialize, ResourceManager rm); @Override void initialize(ResourceManager rm); @Override void addView(TextAnnotation ta);  }