edu.stanford.nlp.trees
Class TransformingTreebank

java.lang.Object
  extended by java.util.AbstractCollection<Tree>
      extended by edu.stanford.nlp.trees.Treebank
          extended by edu.stanford.nlp.trees.TransformingTreebank
All Implemented Interfaces:
java.lang.Iterable<Tree>, java.util.Collection<Tree>

public class TransformingTreebank
extends Treebank

This class wraps another Treebank, and will vend trees that have been through a TreeTransformer. You can access them via requests like apply() or iterator().

Important note: This class will only function properly if the TreeTransformer used is a function (which doesn't change its argument) rather than if it is a TreeMunger.

Author:
Pi-Chuan Chang, Christopher Manning

Field Summary
 
Fields inherited from class edu.stanford.nlp.trees.Treebank
DEFAULT_TREE_FILE_SUFFIX
 
Constructor Summary
TransformingTreebank()
          Create a new TransformingTreebank.
TransformingTreebank(Treebank tb, TreeTransformer transformer)
          Create a new TransformingTreebank from a base Treebank that will transform trees with the given TreeTransformer.
TransformingTreebank(TreeReaderFactory trf)
          Create a new TransformingTreebank.
 
Method Summary
 void apply(TreeVisitor tv)
          Applies the TreeVisitor to to all trees in the Treebank.
 void clear()
          Empty a Treebank.
 java.util.Iterator<Tree> iterator()
           
 void loadPath(java.io.File path, java.io.FileFilter filt)
          Load trees from given path specification.
static void main(java.lang.String[] args)
          Loads treebank grammar from first argument and prints it.
 
Methods inherited from class edu.stanford.nlp.trees.Treebank
decimate, encoding, loadPath, loadPath, loadPath, loadPath, loadPath, remove, size, textualSummary, textualSummary, toString, transform, treeReaderFactory
 
Methods inherited from class java.util.AbstractCollection
add, addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

TransformingTreebank

public TransformingTreebank()
Create a new TransformingTreebank. The trees are made with a LabeledScoredTreeReaderFactory.

Compatibility note: Until Sep 2004, this used to create a Treebank with a SimpleTreeReaderFactory, but this was changed as the old default wasn't very useful, especially to naive users.


TransformingTreebank

public TransformingTreebank(TreeReaderFactory trf)
Create a new TransformingTreebank.

Parameters:
trf - the factory class to be called to create a new TreeReader

TransformingTreebank

public TransformingTreebank(Treebank tb,
                            TreeTransformer transformer)
Create a new TransformingTreebank from a base Treebank that will transform trees with the given TreeTransformer. This is the constructor that you should use.

Parameters:
tb - The base Treebank
transformer - The TreeTransformer applied to each Tree.
Method Detail

clear

public void clear()
Empty a Treebank.

Specified by:
clear in interface java.util.Collection<Tree>
Specified by:
clear in class Treebank

loadPath

public void loadPath(java.io.File path,
                     java.io.FileFilter filt)
Load trees from given path specification.

Specified by:
loadPath in class Treebank
Parameters:
path - file or directory to load from
filt - a FilenameFilter of files to load

apply

public void apply(TreeVisitor tv)
Applies the TreeVisitor to to all trees in the Treebank.

Specified by:
apply in class Treebank
Parameters:
tv - A class that can process trees.

iterator

public java.util.Iterator<Tree> iterator()
Specified by:
iterator in interface java.lang.Iterable<Tree>
Specified by:
iterator in interface java.util.Collection<Tree>
Specified by:
iterator in class java.util.AbstractCollection<Tree>

main

public static void main(java.lang.String[] args)
Loads treebank grammar from first argument and prints it. Just a demonstration of functionality.
usage: java MemoryTreebank treebankFilesPath

Parameters:
args - array of command-line arguments


Stanford NLP Group