@Override public TreeReader newTreeReader(Reader in) { return new PennTreeReader(in, new LabeledScoredTreeFactory(), new NPTmpRetainingTreeNormalizer(NPTmpRetainingTreeNormalizer.TEMPORAL_ACL03PCFG, false, 0, true)); }
private static Iterator<Tree> treebankIterator(String path) { /* Remove empty nodes and strip indices from internal nodes but keep functional tags. */ Treebank tb = new MemoryTreebank(new NPTmpRetainingTreeNormalizer(0, false, 1, false)); tb.loadPath(path); return tb.iterator(); }
/** * An implementation of the <code>TreeReaderFactory</code> interface. * It creates a <code>TreeReader</code> which normalizes trees using * the <code>BobChrisTreeNormalizer</code>, and makes * <code>LabeledScoredTree</code> objects with * <code>CategoryWordTag</code> labels (unless otherwise specified on * construction). */ public TreeReader newTreeReader(Reader in) { return new PennTreeReader(in, new LabeledScoredTreeFactory(lf), tm); } }
@Override public Tree transformTree(Tree t) { //deal with empty root t.setValue(cleanUpRoot(t.value())); //strips tags stripTag(t); // strip empty nodes return stripEmptyNode(t); }
/** * returns a MemoryTreebank appropriate to the testing treebank source */ @Override public MemoryTreebank testMemoryTreebank() { return new MemoryTreebank(in -> new PennTreeReader(in, new LabeledScoredTreeFactory(), new BobChrisTreeNormalizer(tlp))); }
public TreeReader newTreeReader(Reader in) { return new PennTreeReader(in, new LabeledScoredTreeFactory(), new SpanishTreeNormalizer(false, false, false), new PennTreebankTokenizer(in)); }
public Tree transformHelper(Tree tree) { if (tree.isLeaf()) { return transformTerminal(tree); } else { return transformNonterminal(tree); } }
/** * Returns the size of the Treebank. * * @return size How many trees are in the treebank */ @Override public int size() { CounterTreeProcessor counter = new CounterTreeProcessor(); apply(counter); return counter.total(); }
private Tree[] headMarkChildren(Tree t, Tree head) { Tree[] kids = t.children(); Tree[] newKids = new Tree[kids.length]; for (int i = 0, n = kids.length; i < n; i++) { newKids[i] = markHeadNodes(kids[i], head); } return newKids; }
/** * Calls dependenciesToCoNLLXString with the basic dependencies * from a grammatical structure. * * (see {@link #dependenciesToCoNLLXString(Collection, CoreMap)}) */ public static String dependenciesToCoNLLXString(GrammaticalStructure gs, CoreMap sentence) { return dependenciesToCoNLLXString(gs.typedDependencies(), sentence); }
@Override public Tree transformTree(Tree tree) { return normalizeWholeTree(tree, tree.treeFactory()); }
/** */ @Override public Iterator<Tree> iterator() { return new TransformingTreebankIterator(tb.iterator(), transformer); }
/** {@inheritDoc} */ @Override public TokenizerFactory<Tree> treeTokenizerFactory() { return new TreeTokenizerFactory(treeReaderFactory()); }
/** {@inheritDoc} */ @Override public HeadFinder typedDependencyHeadFinder() { if (generateOriginalDependencies) { return new SemanticHeadFinder(this, true); } else { return new UniversalSemanticHeadFinder(this, true); } }
/** * Returns the Constituents generated by the parse tree. Constituents * are computed with respect to whitespace (e.g., at the word level). * * @return a Set of the constituents as constituents of * type {@code Constituent} */ public Set<Constituent> constituents() { return constituents(new SimpleConstituentFactory()); }
@Override public GrammaticalStructure getGrammaticalStructure(Tree t, Predicate<String> filter, HeadFinder hf) { if (generateOriginalDependencies) { return new EnglishGrammaticalStructure(t, filter, hf); } else { return new UniversalEnglishGrammaticalStructure(t, filter, hf); } }
@Override public GrammaticalStructureFactory grammaticalStructureFactory(Predicate<String> puncFilter, HeadFinder hf) { if (generateOriginalDependencies) { return new EnglishGrammaticalStructureFactory(puncFilter, hf); } else { return new UniversalEnglishGrammaticalStructureFactory(puncFilter, hf); } }
@Override public TreeReader newTreeReader(Reader in) { return new PennTreeReader(in, new LabeledScoredTreeFactory(), new NPTmpRetainingTreeNormalizer()); }
/** * Return a GrammaticalStructure suitable for this language/treebank. * * @return A GrammaticalStructure suitable for this language/treebank. */ @Override public GrammaticalStructureFactory grammaticalStructureFactory() { if (generateOriginalDependencies) { return new EnglishGrammaticalStructureFactory(); } else { return new UniversalEnglishGrammaticalStructureFactory(); } }