if (TreeView.isLeaf(parseTreeRoot)) { int position = parseTreeRoot.getStartSpan(); return new Tree<>(new Pair<>(parseTreeRoot.getLabel(), position));
if (TreeView.isLeaf(parseTreeRoot)) { int position = parseTreeRoot.getStartSpan(); return new Tree<>(new Pair<>(parseTreeRoot.getLabel(), position));
@Override public void addView(TextAnnotation ta) { SpanLabelView view = new SpanLabelView(getViewName(), "From " + parseViewName, ta, 1.0, true); TreeView parse = (TreeView) ta.getView(parseViewName); Set<IntPair> set = new LinkedHashSet<>(); for (Constituent c : parse) { if (TreeView.isLeaf(c)) continue; if (ParseTreeProperties.isPreTerminal(c)) continue; String label = c.getLabel(); label = ParseUtils.stripFunctionTags(label); label = ParseUtils.stripIndexReferences(label); // This is the definition used in // Introduction to the CoNLL-2001 Shared Task: // Clause Identification if (label.startsWith("S") && !label.equals("S1")) { int start = c.getStartSpan(); int end = c.getEndSpan(); if (start >= 0 && end > start) { set.add(new IntPair(start, end)); } } } for (IntPair span : set) { view.addSpanLabel(span.getFirst(), span.getSecond(), "S", 1.0); } ta.addView(getViewName(), view); }
public Tree<String> getDependencyTree(Constituent parseTreeRoot) { // for each parse non-terminal, starting from the root, find the head. // Make a dependency arc from the all the other children to the head // child. if (TreeView.isLeaf(parseTreeRoot)) return new Tree<>(parseTreeRoot.getTokenizedSurfaceForm()); Constituent headWord = headFinder.getHeadWord(parseTreeRoot); Constituent headChild = headFinder.getHeadChild(parseTreeRoot); Tree<String> rootTree = new Tree<>(headWord.getTokenizedSurfaceForm()); List<Tree<String>> dependentTrees = new ArrayList<>(); for (Relation childEdge : parseTreeRoot.getOutgoingRelations()) { Constituent child = childEdge.getTarget(); if (child.equals(headChild)) { rootTree = getDependencyTree(child); } else { dependentTrees.add(getDependencyTree(child)); } } rootTree.addSubtrees(dependentTrees); return rootTree; }
public Tree<String> getDependencyTree(Constituent parseTreeRoot) { // for each parse non-terminal, starting from the root, find the head. // Make a dependency arc from the all the other children to the head // child. if (TreeView.isLeaf(parseTreeRoot)) return new Tree<>(parseTreeRoot.getTokenizedSurfaceForm()); Constituent headWord = headFinder.getHeadWord(parseTreeRoot); Constituent headChild = headFinder.getHeadChild(parseTreeRoot); Tree<String> rootTree = new Tree<>(headWord.getTokenizedSurfaceForm()); List<Tree<String>> dependentTrees = new ArrayList<>(); for (Relation childEdge : parseTreeRoot.getOutgoingRelations()) { Constituent child = childEdge.getTarget(); if (child.equals(headChild)) { rootTree = getDependencyTree(child); } else { dependentTrees.add(getDependencyTree(child)); } } rootTree.addSubtrees(dependentTrees); return rootTree; }
@Override public void addView(TextAnnotation ta) { SpanLabelView view = new SpanLabelView(getViewName(), "From " + parseViewName, ta, 1.0, true); TreeView parse = (TreeView) ta.getView(parseViewName); Set<IntPair> set = new LinkedHashSet<>(); for (Constituent c : parse) { if (TreeView.isLeaf(c)) continue; if (ParseTreeProperties.isPreTerminal(c)) continue; String label = c.getLabel(); label = ParseUtils.stripFunctionTags(label); label = ParseUtils.stripIndexReferences(label); // This is the definition used in // Introduction to the CoNLL-2001 Shared Task: // Clause Identification if (label.startsWith("S") && !label.equals("S1")) { int start = c.getStartSpan(); int end = c.getEndSpan(); if (start >= 0 && end > start) { set.add(new IntPair(start, end)); } } } for (IntPair span : set) { view.addSpanLabel(span.getFirst(), span.getSecond(), "S", 1.0); } ta.addView(getViewName(), view); }