edu.stanford.nlp.trees.CompositeTreeTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-parser Show documentation
Show all versions of stanford-parser Show documentation
Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.
package edu.stanford.nlp.trees;
import java.util.List;
import java.util.ArrayList;
/**
* A TreeTransformer that applies component TreeTransformers in order.
* The order in which they are applied is the order in which they are added or
* the order in which they appear in the List passed to the constructor.
*
* @author Galen Andrew
*/
public class CompositeTreeTransformer implements TreeTransformer {
private final List transformers = new ArrayList();
public CompositeTreeTransformer() {
}
public CompositeTreeTransformer(List tt) {
transformers.addAll(tt);
}
public void addTransformer(TreeTransformer tt) {
transformers.add(tt);
}
public Tree transformTree(Tree t) {
for (TreeTransformer tt : transformers) {
t = tt.transformTree(t);
}
return t;
}
@Override
public String toString() {
return "CompositeTreeTransformer: " + transformers;
}
}