Skip to content

Commit

Permalink
Add the ability to EnglishPTBTreebankCorrector to use it as a TreeTra…
Browse files Browse the repository at this point in the history
…nsformer with a single transformation, rather than on an entire treebank
  • Loading branch information
AngledLuffa committed Mar 20, 2024
1 parent aef5e36 commit 1f11e3f
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -19,7 +19,7 @@
* You can use this class from {@link edu.stanford.nlp.trees.Treebanks} via a command like: <p>
* {@code java edu.stanford.nlp.trees.Treebanks -correct -pennPrint LDC99T42-Treebank3/parsed/mrg/wsj 200-2199 > train-fixed}
*/
public class EnglishPTBTreebankCorrector implements TreebankTransformer {
public class EnglishPTBTreebankCorrector implements TreeTransformer, TreebankTransformer {

/** A logger for this class */
private static final Redwood.RedwoodChannels log = Redwood.channels(EnglishPTBTreebankCorrector.class);
Expand Down Expand Up @@ -100,14 +100,19 @@ public EnglishPTBTreebankCorrector() {
}
}

@Override
public Tree transformTree(Tree t) {
return Tsurgeon.processPatternsOnTree(ops, t);
}

/** Fix all the English Penn Treebank errors, or at least some of them (!).
*/
@Override
public MemoryTreebank transformTrees(Treebank tb) {
MemoryTreebank mtb = new MemoryTreebank(tb.treeReaderFactory(),
tb.encoding());
for (Tree t : tb) {
mtb.add(Tsurgeon.processPatternsOnTree(ops, t));
mtb.add(transformTree(t));
}
return mtb;
}
Expand Down

0 comments on commit 1f11e3f

Please sign in to comment.