Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.trees
Class TransformingTreebank

    java.lang.Object
      java.util.AbstractCollection<Tree>
          edu.stanford.nlp.trees.Treebank
              edu.stanford.nlp.trees.TransformingTreebank

All Implemented Interfaces:
  Iterable<Tree>, 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 TreeTransfomer 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`.
`Iterator<Tree>` | `iterator()`
`void` | `loadPath(File path, FileFilter filt)` Load trees from given path specification.
`static void` | `main(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 `Collection<Tree>`
  Specified by:
    `clear` in class `Treebank`

### loadPath

    public void loadPath(File path,
                         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 Iterator<Tree> iterator()

  Specified by:
    `iterator` in interface `Iterable<Tree>`
  Specified by:
    `iterator` in interface `Collection<Tree>`
  Specified by:
    `iterator` in class `AbstractCollection<Tree>`

### main

    public static void main(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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group