edu.stanford.nlp.trees
Class RecursiveTreeTransformer
java.lang.Object
edu.stanford.nlp.trees.RecursiveTreeTransformer
- All Implemented Interfaces:
- TreeTransformer
- Direct Known Subclasses:
- BasicCategoryTreeTransformer
public abstract class RecursiveTreeTransformer
- extends java.lang.Object
- implements TreeTransformer
A tool to recursively alter a tree in various ways. For example,
BasicCategoryTreeTransformer
turns all the non-leaf labels of a tree into their basic categories
given a set of treebank parameters which describe how to turn the
basic categories.
There are three easy places to override and implement the needed
behavior. transformTerminalLabel changes the labels of the
terminals, transformNonterminalLabel changes the labels of the
non-terminals, and transformLabel changes all labels. If the tree
needs to be changed in different ways, transformTerminal or
transformNonterminal can be used instead.
- Author:
- John Bauer
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RecursiveTreeTransformer
public RecursiveTreeTransformer()
transformTree
public Tree transformTree(Tree tree)
- Description copied from interface:
TreeTransformer
- Does whatever one needs to do to a particular tree.
This routine is passed a whole
Tree, and could itself
work recursively, but the canonical usage is to invoke this method
via the Tree.transform() method, which will apply the
transformer in a bottom-up manner to each local Tree,
and hence the implementation of TreeTransformer should
merely examine and change a local (one-level) Tree.
- Specified by:
transformTree in interface TreeTransformer
- Parameters:
tree - A tree. Classes implementing this interface can assume
that the tree passed in is not null.
- Returns:
- the transformed
Tree
transformHelper
public Tree transformHelper(Tree tree)
transformTerminal
public Tree transformTerminal(Tree tree)
transformNonterminal
public Tree transformNonterminal(Tree tree)
transformTerminalLabel
public Label transformTerminalLabel(Tree tree)
transformNonterminalLabel
public Label transformNonterminalLabel(Tree tree)
transformLabel
public Label transformLabel(Tree tree)
Stanford NLP Group