/** * Returns a Filter which checks dependencies for usefulness as * extra tree-based dependencies. By default, everything is * accepted. One example of how this can be useful is in the * English dependencies, where the REL dependency is used as an * intermediate and we do not want this to be added when we make a * second pass over the trees for missing dependencies. */ protected Predicate<TypedDependency> extraTreeDepFilter() { return Filters.acceptFilter(); }
/** * @param headFinder If a headFinder is provided, then head percolation will be done * for trees. Otherwise, it must be called separately. */ public UnlabeledAttachmentEval(String str, boolean runningAverages, HeadFinder headFinder) { this(str, runningAverages, headFinder, Filters.<String>acceptFilter()); }
public GrammaticalStructure(List<TypedDependency> projectiveDependencies, TreeGraphNode root) { this.root = root; indexNodes(this.root); this.puncFilter = Filters.acceptFilter(); this.tagFilter = Filters.acceptFilter(); allTypedDependencies = typedDependencies = new ArrayList<>(projectiveDependencies); }
/** * Return a Set of TaggedWord-TaggedWord dependencies, represented as * Dependency objects, for the Tree. This will only give * useful results if the internal tree node labels support HasWord and * HasTag, and head percolation has already been done (see * percolateHeads()). * * @return Set of dependencies (each a Dependency) */ public Set<Dependency<Label, Label, Object>> dependencies() { return dependencies(Filters.acceptFilter()); }
public Predicate<String> getPattern(String relnType) { if ((relnType == null) || (relnType.equals(""))) { return Filters.acceptFilter(); } else if (relnType.matches("/.*/")) { return new RegexStringFilter(relnType.substring(1, relnType.length() - 1)); } else { // raw description return new ArrayStringFilter(ArrayStringFilter.Mode.EXACT, relnType); } }
public ChineseGrammaticalStructure(Tree t, Predicate<String> puncFilter, HeadFinder hf) { super(t, ChineseGrammaticalRelations.values(), ChineseGrammaticalRelations.valuesLock(), null, hf, puncFilter, Filters.acceptFilter()); }
public UniversalChineseGrammaticalStructure(Tree t, Predicate<String> puncFilter, HeadFinder hf) { super(t, UniversalChineseGrammaticalRelations.values(), UniversalChineseGrammaticalRelations.valuesLock(), null, hf, puncFilter, Filters.acceptFilter()); }
/** * Construct a new {@code GrammaticalStructure} from an existing parse * tree. The new {@code GrammaticalStructure} has the same tree structure * and label values as the given tree (but no shared storage). As part of * construction, the parse tree is analyzed using definitions from * {@link GrammaticalRelation {@code GrammaticalRelation}} to populate * the new {@code GrammaticalStructure} with as many labeled grammatical * relations as it can. * * This gets used by GrammaticalStructureFactory (by reflection). DON'T DELETE. * * @param t Parse tree to make grammatical structure from * @param tagFilter Filter for punctuation tags * @param hf HeadFinder to use when building it */ public UniversalEnglishGrammaticalStructure(Tree t, Predicate<String> tagFilter, HeadFinder hf) { // the tree is normalized (for index and functional tag stripping) inside CoordinationTransformer super(t, UniversalEnglishGrammaticalRelations.values(), UniversalEnglishGrammaticalRelations.valuesLock(), new CoordinationTransformer(hf, true), hf, Filters.acceptFilter(), tagFilter); }
/** * Construct a new {@code GrammaticalStructure} from an existing parse * tree. The new {@code GrammaticalStructure} has the same tree structure * and label values as the given tree (but no shared storage). As part of * construction, the parse tree is analyzed using definitions from * {@link GrammaticalRelation {@code GrammaticalRelation}} to populate * the new {@code GrammaticalStructure} with as many labeled grammatical * relations as it can. * * Once upon a time this method had an extra parameter as to whether to operate * in a threadsafe manner. We decided that that was a really bad idea, and this * method now always acts in a threadsafe manner. * This method gets used by GrammaticalStructureFactory (by reflection). DON'T DELETE. * * @param t Parse tree to make grammatical structure from * @param puncFilter Filter for punctuation words * @param hf HeadFinder to use when building it */ public EnglishGrammaticalStructure(Tree t, Predicate<String> puncFilter, HeadFinder hf) { // the tree is normalized (for index and functional tag stripping) inside CoordinationTransformer super(t, EnglishGrammaticalRelations.values(), EnglishGrammaticalRelations.valuesLock(), new CoordinationTransformer(hf), hf, puncFilter, Filters.acceptFilter()); }
public GsIterator() { if (keepPunct) { puncFilter = Filters.acceptFilter(); } else if (params.generateOriginalDependencies()) { puncFilter = params.treebankLanguagePack().punctuationWordRejectFilter(); } else { puncFilter = params.treebankLanguagePack().punctuationTagRejectFilter(); } hf = params.typedDependencyHeadFinder(); primeGs(); }
private void setDependencyTree(Annotation anno) { List<CoreMap> sentences = anno.get(SentencesAnnotation.class); for(CoreMap sentence : sentences) { Tree tree = sentence.get(TreeAnnotation.class); if (tree==null) continue; SemanticGraph deps = null; SemanticGraph basicDeps = null; if (options.lang == Locale.CHINESE) { final boolean threadSafe = true; deps = SemanticGraphFactory.makeFromTree( new ChineseGrammaticalStructure(tree, Filters.acceptFilter(), chineseHeadFinder), SemanticGraphFactory.Mode.COLLAPSED, GrammaticalStructure.Extras.NONE, null); basicDeps = SemanticGraphFactory.makeFromTree( new ChineseGrammaticalStructure(tree, Filters.acceptFilter(), chineseHeadFinder), SemanticGraphFactory.Mode.BASIC, GrammaticalStructure.Extras.NONE, null); } else { deps = SemanticGraphFactory.generateEnhancedDependencies(tree); basicDeps = SemanticGraphFactory.generateUncollapsedDependencies(tree); } sentence.set(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class, basicDeps); sentence.set(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class, deps); } }
Predicate<String> wordFilt; if (includePunctuationDependencies) { wordFilt = Filters.acceptFilter(); } else { wordFilt = new PennTreebankLanguagePack().punctuationWordRejectFilter(); Predicate<String> tagFilt; if (includePunctuationDependencies) { tagFilt = Filters.acceptFilter(); } else { tagFilt = new PennTreebankLanguagePack().punctuationTagRejectFilter();
dependencyFilter = Filters.acceptFilter(); dependencyWordFilter = Filters.acceptFilter(); puncFilter = Filters.acceptFilter(); } else { dependencyFilter = new Dependencies.DependentPuncTagRejectFilter<>(tlp.punctuationTagRejectFilter());
List<Dependency<Label, Label, Object>> sortedDeps = getSortedDeps(it, Filters.acceptFilter());
parser.getTLPParams().setGenerateOriginalDependencies(generateOriginalDependencies); TreebankLanguagePack tlp = parser.getTLPParams().treebankLanguagePack(); Predicate<String> punctFilter = this.keepPunct ? Filters.acceptFilter() : tlp.punctuationWordRejectFilter(); this.gsf = tlp.grammaticalStructureFactory(punctFilter, parser.getTLPParams().typedDependencyHeadFinder()); } else {
/** * @param headFinder If a headFinder is provided, then head percolation will be done * for trees. Otherwise, it must be called separately. */ public UnlabeledAttachmentEval(String str, boolean runningAverages, HeadFinder headFinder) { this(str, runningAverages, headFinder, Filters.<String>acceptFilter()); }
/** * @param headFinder If a headFinder is provided, then head percolation will be done * for trees. Otherwise, it must be called separately. */ public UnlabeledAttachmentEval(String str, boolean runningAverages, HeadFinder headFinder) { this(str, runningAverages, headFinder, Filters.<String>acceptFilter()); }
public GrammaticalStructure(List<TypedDependency> projectiveDependencies, TreeGraphNode root) { this.root = root; indexNodes(this.root); this.puncFilter = Filters.acceptFilter(); this.tagFilter = Filters.acceptFilter(); allTypedDependencies = typedDependencies = new ArrayList<>(projectiveDependencies); }
/** * Return a Set of TaggedWord-TaggedWord dependencies, represented as * Dependency objects, for the Tree. This will only give * useful results if the internal tree node labels support HasWord and * HasTag, and head percolation has already been done (see * percolateHeads()). * * @return Set of dependencies (each a Dependency) */ public Set<Dependency<Label, Label, Object>> dependencies() { return dependencies(Filters.acceptFilter()); }
public GsIterator() { if (keepPunct) { puncFilter = Filters.acceptFilter(); } else { puncFilter = new PennTreebankLanguagePack().punctuationWordRejectFilter(); } hf = new SemanticHeadFinder( ! makeCopulaHead); primeGs(); }