private List<Dependency<Label, Label, Object>> getSortedDeps(Tree tree, Predicate<Dependency<Label, Label, Object>> filter) { if (gsf != null) { GrammaticalStructure gs = gsf.newGrammaticalStructure(tree); Collection<TypedDependency> deps = gs.typedDependencies(GrammaticalStructure.Extras.NONE); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(); for (TypedDependency dep : deps) { sortedDeps.add(new NamedDependency(dep.gov(), dep.dep(), dep.reln().toString())); } Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } else { Set<Dependency<Label, Label, Object>> depsSet = tree.mapDependencies(filter, hf, "root"); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } }
/** * Return a set of Label-Label dependencies, represented as * Dependency objects, for the Tree. The Labels are the ones of the leaf * nodes of the tree, without mucking with them. The head of the sentence is a * dependent of a synthetic "root" label. * * @param f Dependencies are excluded for which the Dependency is not * accepted by the Filter * @param hf The HeadFinder to use to identify the head of constituents. * The code assumes * that it can use {@code headPreTerminal(hf)} to find a * tag and word to make a CoreLabel. * @param rootName Name of the root node. * @return Set of dependencies (each a {@code Dependency} between two * {@code CoreLabel}s, which each contain a tag(), word(), * and value(), the last two of which are identical). */ public Set<Dependency<Label, Label, Object>> mapDependencies(Predicate<Dependency<Label, Label, Object>> f, HeadFinder hf, String rootName) { Set<Dependency<Label, Label, Object>> deps = mapDependencies(f, hf); if(rootName != null) { Label hl = headTerminal(hf).label(); CoreLabel rl = new CoreLabel(); rl.set(CoreAnnotations.TextAnnotation.class, rootName); rl.set(CoreAnnotations.IndexAnnotation.class, 0); deps.add(new NamedDependency(rl, hl, rootName)); } return deps; }
CoreLabel.factory()); indexedTree.indexLeaves(); Set<Dependency<Label, Label, Object>> depsSet = indexedTree.mapDependencies(dependencyWordFilter, hf); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(depsSet); sortedDeps.sort(Dependencies.dependencyIndexComparator()); boolean failed = false; try { depsSet = indexedTree.mapDependencies(dependencyFilter, hf); } catch (Exception e) { failed = true;
private List<Dependency<Label, Label, Object>> getSortedDeps(Tree tree, Predicate<Dependency<Label, Label, Object>> filter) { if (gsf != null) { GrammaticalStructure gs = gsf.newGrammaticalStructure(tree); Collection<TypedDependency> deps = gs.typedDependencies(GrammaticalStructure.Extras.NONE); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(); for (TypedDependency dep : deps) { sortedDeps.add(new NamedDependency(dep.gov(), dep.dep(), dep.reln().toString())); } Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } else { Set<Dependency<Label, Label, Object>> depsSet = tree.mapDependencies(filter, hf, "root"); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } }
private List<Dependency<Label, Label, Object>> getSortedDeps(Tree tree, Predicate<Dependency<Label, Label, Object>> filter) { if (gsf != null) { GrammaticalStructure gs = gsf.newGrammaticalStructure(tree); Collection<TypedDependency> deps = gs.typedDependencies(GrammaticalStructure.Extras.NONE); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(); for (TypedDependency dep : deps) { sortedDeps.add(new NamedDependency(dep.gov(), dep.dep(), dep.reln().toString())); } Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } else { Set<Dependency<Label, Label, Object>> depsSet = tree.mapDependencies(filter, hf, "root"); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } }
private List<Dependency<Label, Label, Object>> getSortedDeps(Tree tree, Filter<Dependency<Label, Label, Object>> filter) { if (gsf != null) { GrammaticalStructure gs = gsf.newGrammaticalStructure(tree); Collection<TypedDependency> deps = gs.typedDependencies(false); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<Dependency<Label, Label, Object>>(); for (TypedDependency dep : deps) { sortedDeps.add(new NamedDependency(dep.gov().label(), dep.dep().label(), dep.reln().toString())); } Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } else { Set<Dependency<Label, Label, Object>> depsSet = tree.mapDependencies(filter, hf, "root"); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<Dependency<Label, Label, Object>>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); return sortedDeps; } }
/** * Return a set of Label-Label dependencies, represented as * Dependency objects, for the Tree. The Labels are the ones of the leaf * nodes of the tree, without mucking with them. The head of the sentence is a * dependent of a synthetic "root" label. * * @param f Dependencies are excluded for which the Dependency is not * accepted by the Filter * @param hf The HeadFinder to use to identify the head of constituents. * The code assumes * that it can use {@code headPreTerminal(hf)} to find a * tag and word to make a CoreLabel. * @param rootName Name of the root node. * @return Set of dependencies (each a {@code Dependency} between two * {@code CoreLabel}s, which each contain a tag(), word(), * and value(), the last two of which are identical). */ public Set<Dependency<Label, Label, Object>> mapDependencies(Predicate<Dependency<Label, Label, Object>> f, HeadFinder hf, String rootName) { Set<Dependency<Label, Label, Object>> deps = mapDependencies(f, hf); if(rootName != null) { Label hl = headTerminal(hf).label(); CoreLabel rl = new CoreLabel(); rl.set(CoreAnnotations.TextAnnotation.class, rootName); rl.set(CoreAnnotations.IndexAnnotation.class, 0); deps.add(new NamedDependency(rl, hl, rootName)); } return deps; }
/** * Return a set of Label-Label dependencies, represented as * Dependency objects, for the Tree. The Labels are the ones of the leaf * nodes of the tree, without mucking with them. The head of the sentence is a * dependent of a synthetic "root" label. * * @param f Dependencies are excluded for which the Dependency is not * accepted by the Filter * @param hf The HeadFinder to use to identify the head of constituents. * The code assumes * that it can use {@code headPreTerminal(hf)} to find a * tag and word to make a CoreLabel. * @param rootName Name of the root node. * @return Set of dependencies (each a {@code Dependency} between two * {@code CoreLabel}s, which each contain a tag(), word(), * and value(), the last two of which are identical). */ public Set<Dependency<Label, Label, Object>> mapDependencies(Predicate<Dependency<Label, Label, Object>> f, HeadFinder hf, String rootName) { Set<Dependency<Label, Label, Object>> deps = mapDependencies(f, hf); if(rootName != null) { Label hl = headTerminal(hf).label(); CoreLabel rl = new CoreLabel(); rl.set(CoreAnnotations.TextAnnotation.class, rootName); rl.set(CoreAnnotations.IndexAnnotation.class, 0); deps.add(new NamedDependency(rl, hl, rootName)); } return deps; }
/** * Return a set of Label-Label dependencies, represented as * Dependency objects, for the Tree. The Labels are the ones of the leaf * nodes of the tree, without mucking with them. The head of the sentence is a * dependent of a synthetic "root" label. * * @param f Dependencies are excluded for which the Dependency is not * accepted by the Filter * @param hf The HeadFinder to use to identify the head of constituents. * The code assumes * that it can use <code>headPreTerminal(hf)</code> to find a * tag and word to make a CoreLabel. * @param rootName Name of the root node. * @return Set of dependencies (each a <code>Dependency</code> between two * <code>CoreLabel</code>s, which each contain a tag(), word(), * and value(), the last two of which are identical). */ public Set<Dependency<Label, Label, Object>> mapDependencies(Filter<Dependency<Label, Label, Object>> f, HeadFinder hf, String rootName) { Set<Dependency<Label, Label, Object>> deps = mapDependencies(f, hf); if(rootName != null) { Label hl = headTerminal(hf).label(); CoreLabel rl = new CoreLabel(); rl.set(CoreAnnotations.TextAnnotation.class, rootName); rl.set(CoreAnnotations.IndexAnnotation.class, 0); deps.add(new NamedDependency(rl, hl, rootName)); } return deps; }
/** * Return a set of Label-Label dependencies, represented as * Dependency objects, for the Tree. The Labels are the ones of the leaf * nodes of the tree, without mucking with them. The head of the sentence is a * dependent of a synthetic "root" label. * * @param f Dependencies are excluded for which the Dependency is not * accepted by the Filter * @param hf The HeadFinder to use to identify the head of constituents. * The code assumes * that it can use <code>headPreTerminal(hf)</code> to find a * tag and word to make a CoreLabel. * @param rootName Name of the root node. * @return Set of dependencies (each a <code>Dependency</code> between two * <code>CoreLabel</code>s, which each contain a tag(), word(), * and value(), the last two of which are identical). */ public Set<Dependency<Label, Label, Object>> mapDependencies(Filter<Dependency<Label, Label, Object>> f, HeadFinder hf, String rootName) { Set<Dependency<Label, Label, Object>> deps = mapDependencies(f, hf); if(rootName != null) { Label hl = headTerminal(hf).label(); CoreLabel rl = new CoreLabel(); rl.set(TextAnnotation.class, rootName); rl.set(IndexAnnotation.class, 0); deps.add(new NamedDependency(rl, hl, rootName)); } return deps; }
CoreLabel.factory()); indexedTree.indexLeaves(); Set<Dependency<Label, Label, Object>> depsSet = indexedTree.mapDependencies(dependencyWordFilter, hf); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<Dependency<Label, Label, Object>>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); CyclicCoreLabel.factory()); indexedTree.indexLeaves(); Set<Dependency<Label, Label, Object>> depsSet = indexedTree.mapDependencies(dependencyWordFilter, hf); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<Dependency<Label, Label, Object>>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); Set<Dependency<Label, Label, Object>> depsSet = it.mapDependencies(dependencyFilter, hf, "root"); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<Dependency<Label, Label, Object>>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); boolean failed = false; try { depsSet = indexedTree.mapDependencies(dependencyFilter, hf); } catch (Exception e) { failed = true;
CoreLabel.factory()); indexedTree.indexLeaves(); Set<Dependency<Label, Label, Object>> depsSet = indexedTree.mapDependencies(dependencyWordFilter, hf); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<Dependency<Label, Label, Object>>(depsSet); Collections.sort(sortedDeps, Dependencies.dependencyIndexComparator()); boolean failed = false; try { depsSet = indexedTree.mapDependencies(dependencyFilter, hf); } catch (Exception e) { failed = true;
CoreLabel.factory()); indexedTree.indexLeaves(); Set<Dependency<Label, Label, Object>> depsSet = indexedTree.mapDependencies(dependencyWordFilter, hf); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(depsSet); sortedDeps.sort(Dependencies.dependencyIndexComparator()); boolean failed = false; try { depsSet = indexedTree.mapDependencies(dependencyFilter, hf); } catch (Exception e) { failed = true;
CoreLabel.factory()); indexedTree.indexLeaves(); Set<Dependency<Label, Label, Object>> depsSet = indexedTree.mapDependencies(dependencyWordFilter, hf); List<Dependency<Label, Label, Object>> sortedDeps = new ArrayList<>(depsSet); sortedDeps.sort(Dependencies.dependencyIndexComparator()); boolean failed = false; try { depsSet = indexedTree.mapDependencies(dependencyFilter, hf); } catch (Exception e) { failed = true;