edu.stanford.nlp.trees
Class TreeNormalizer

java.lang.Object
  extended by edu.stanford.nlp.trees.TreeNormalizer
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BobChrisTreeNormalizer, NegraPennTreeNormalizer

public class TreeNormalizer
extends Object
implements Serializable

A class for tree normalization. The default one does no normalization. Other tree normalizers will change various node labels, or perhaps the whole tree geometry (by doing such things as deleting functional tags or empty elements). Another operation that a TreeNormalizer may wish to perform is interning the Strings passed to it. A Singleton. Designed to be extended.

The TreeNormalizer methods are in two groups. The contract for this class is that first normalizeTerminal or normalizeNonterminal will be called on each String that will be put into a Tree, when they are read from files or otherwise created. Then normalizeWholeTree will be called on the Tree. It normally walks the Tree making whatever modifications it wishes to. A TreeNormalizer need not make a deep copy of a Tree. It is assumed to be able to work destructively, because afterwards we will only use the normalized Tree.

Implementation note: This is a very old legacy class used in conjunction with PennTreeReader. It seems now that it would be better to move the String normalization into the tokenizer, and then we are just left with a (posibly destructive) TreeTransformer.

Author:
Christopher Manning
See Also:
Serialized Form

Constructor Summary
TreeNormalizer()
           
 
Method Summary
 String normalizeNonterminal(String category)
          Normalizes a nonterminal contents (and maybe intern it).
 String normalizeTerminal(String leaf)
          Normalizes a leaf contents (and maybe intern it).
 Tree normalizeWholeTree(Tree tree, TreeFactory tf)
          Normalize a whole tree -- this method assumes that the argument that it is passed is the root of a complete Tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeNormalizer

public TreeNormalizer()
Method Detail

normalizeTerminal

public String normalizeTerminal(String leaf)
Normalizes a leaf contents (and maybe intern it).

Parameters:
leaf - The String that decorates the leaf
Returns:
The normalized form of this leaf String

normalizeNonterminal

public String normalizeNonterminal(String category)
Normalizes a nonterminal contents (and maybe intern it).

Parameters:
category - The String that decorates this nonterminal node
Returns:
The normalized form of this nonterminal String

normalizeWholeTree

public Tree normalizeWholeTree(Tree tree,
                               TreeFactory tf)
Normalize a whole tree -- this method assumes that the argument that it is passed is the root of a complete Tree. It is normally implemented as a Tree-walking routine.

Parameters:
tree - The tree to be normalized
tf - the TreeFactory to create new nodes (if needed)
Returns:
Tree the normalized tree


Stanford NLP Group