Class BobChrisTreeNormalizer
- java.lang.Object
-
- edu.stanford.nlp.trees.TreeNormalizer
-
- edu.stanford.nlp.trees.BobChrisTreeNormalizer
-
- All Implemented Interfaces:
TreeTransformer,Serializable,Function<Tree,Tree>
- Direct Known Subclasses:
ArabicTreeNormalizer,CharacterLevelTagExtender,CTBErrorCorrectingTreeNormalizer,FrenchTreeNormalizer,HebrewTreeNormalizer,NPTmpRetainingTreeNormalizer,SpanishTreeNormalizer
public class BobChrisTreeNormalizer extends TreeNormalizer implements TreeTransformer
Normalizes trees in the way used in Manning and Carpenter 1997. NB: This implementation is still incomplete! The normalizations performed are: (i) terminals are interned, (ii) nonterminals are stripped of alternants, functional tags and cross-reference codes, and then interned, (iii) empty elements (ones with nonterminal label "-NONE-") are deleted from the tree, (iv) the null label at the root node is replaced with the label "ROOT".
17 Apr 2001: This was fixed to work with different kinds of labels, by making proper use of the Label interface, after it was moved into the trees module.The normalizations of the original (Prolog) BobChrisNormalize were: 1. Remap the root node to be called 'ROOT' 2. Truncate all nonterminal labels before characters introducing annotations according to TreebankLanguagePack (traditionally, -, =, | or # (last for BLLIP)) 3. Remap the representation of certain leaf symbols (brackets etc.) 4. Map to lowercase all leaf nodes 5. Delete empty/trace nodes (ones marked '-NONE-') 6. Recursively delete any nodes that do not dominate any words 7. Delete A over A nodes where the top A dominates nothing else 8. Remove backslashes from lexical items (the Treebank inserts them to escape slashes (/) and stars (*)). 4 is deliberately omitted, and a few things are purely aesthetic.
14 June 2002: It now deletes unary A over A if both nodes' labels are equal (7), and (6) was always part of the Tree.prune() functionality... 30 June 2005: Also splice out an EDITED node, just in case you're parsing the Brown corpus.
- Author:
- Christopher Manning
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBobChrisTreeNormalizer.AOverAFilterstatic classBobChrisTreeNormalizer.EmptyFilter
-
Field Summary
Fields Modifier and Type Field Description protected Predicate<Tree>aOverAFilterprotected Predicate<Tree>emptyFilterprotected TreebankLanguagePacktlp
-
Constructor Summary
Constructors Constructor Description BobChrisTreeNormalizer()BobChrisTreeNormalizer(TreebankLanguagePack tlp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringcleanUpLabel(String label)Remove things like hyphened functional tags and equals from the end of a node label.StringnormalizeNonterminal(String category)Normalizes a nonterminal contents.StringnormalizeTerminal(String leaf)Normalizes a leaf contents.TreenormalizeWholeTree(Tree tree, TreeFactory tf)Normalize a whole tree -- one can assume that this is the root.TreetransformTree(Tree tree)Does whatever one needs to do to a particular tree.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.stanford.nlp.trees.TreeTransformer
apply
-
-
-
-
Field Detail
-
tlp
protected final TreebankLanguagePack tlp
-
-
Constructor Detail
-
BobChrisTreeNormalizer
public BobChrisTreeNormalizer()
-
BobChrisTreeNormalizer
public BobChrisTreeNormalizer(TreebankLanguagePack tlp)
-
-
Method Detail
-
normalizeTerminal
public String normalizeTerminal(String leaf)
Normalizes a leaf contents. This implementation interns the leaf.- Overrides:
normalizeTerminalin classTreeNormalizer- 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. This implementation strips functional tags, etc. and interns the nonterminal.- Overrides:
normalizeNonterminalin classTreeNormalizer- Parameters:
category- The String that decorates this nonterminal node- Returns:
- The normalized form of this nonterminal String
-
cleanUpLabel
protected String cleanUpLabel(String label)
Remove things like hyphened functional tags and equals from the end of a node label. This version always just returns the phrase structure category, or "ROOT" if the label wasnull.- Parameters:
label- The label from the treebank- Returns:
- The cleaned up label (phrase structure category)
-
normalizeWholeTree
public Tree normalizeWholeTree(Tree tree, TreeFactory tf)
Normalize a whole tree -- one can assume that this is the root. This implementation deletes empty elements (ones with nonterminal tag label '-NONE-') from the tree, and splices out unary A over A nodes. It assumes that it is not given a null tree, but it may return one if there are no real words.- Overrides:
normalizeWholeTreein classTreeNormalizer- Parameters:
tree- The tree to be normalizedtf- the TreeFactory to create new nodes (if needed)- Returns:
- The normalized tree. May be null which means to not use this tree at all.
-
transformTree
public Tree transformTree(Tree tree)
Description copied from interface:TreeTransformerDoes whatever one needs to do to a particular tree. This routine is passed a wholeTree, and could itself work recursively, but the canonical usage is to invoke this method via theTree.transform()method, which will apply the transformer in a bottom-up manner to each localTree, and hence the implementation ofTreeTransformershould merely examine and change a local (one-level)Tree.- Specified by:
transformTreein interfaceTreeTransformer- Parameters:
tree- A tree. Classes implementing this interface can assume that the tree passed in is notnull.- Returns:
- The transformed
Tree
-
-