edu.stanford.nlp.trees.OrderedCombinationTreeNormalizer 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.ArrayList;
import java.util.List;
/**
* This class combines multiple tree normalizers. Given a list of tree normalizer,
* it applies each tree normalizer from the first to the last for each of the normalize
* nonterminal, normalize terminal, and normalize whole tree methods.
*
*
* @author Anna Rafferty
*
*/
public class OrderedCombinationTreeNormalizer extends TreeNormalizer {
private static final long serialVersionUID = 326L;
private List tns = new ArrayList();
public OrderedCombinationTreeNormalizer() {
}
public OrderedCombinationTreeNormalizer(List tns) {
this.tns = tns;
}
/**
* Adds the given tree normalizer to this combination; the tree normalizers
* are applied in the order they were added, with the first to be added being
* the first to be applied.
*/
public void addTreeNormalizer(TreeNormalizer tn) {
this.tns.add(tn);
}
@Override
public String normalizeNonterminal(String category) {
for(TreeNormalizer tn : tns) {
category = tn.normalizeNonterminal(category);
}
return category;
}
@Override
public String normalizeTerminal(String leaf) {
for(TreeNormalizer tn : tns) {
leaf = tn.normalizeTerminal(leaf);
}
return leaf;
}
@Override
public Tree normalizeWholeTree(Tree tree, TreeFactory tf) {
for(TreeNormalizer tn : tns) {
tree = tn.normalizeWholeTree(tree, tf);
}
return tree;
}
}