edu.stanford.nlp.trees
Class Treebank

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--edu.stanford.nlp.trees.Treebank
All Implemented Interfaces:
Collection
Direct Known Subclasses:
DiskTreebank, MemoryTreebank

public abstract class Treebank
extends AbstractCollection

A Treebank object provides access to a corpus of examples with given tree structures. This class now implements the Collection interface. However, it may offer less than the full power of the Collection interface: some Treebanks are read only, and so may throw the UnsupportedOperationException.


Constructor Summary
Treebank()
          Create a new Treebank (using a SimpleTreeReaderFactory).
Treebank(int initialCapacity)
          Create a new Treebank.
Treebank(int initialCapacity, TreeReaderFactory trf)
          Create a new Treebank.
Treebank(TreeReaderFactory trf)
          Create a new Treebank.
 
Method Summary
abstract  void apply(TreeProcessor tp)
          Apply a TreeProcessor to each tree in the Treebank.
abstract  void clear()
          Empty a Treebank.
abstract  Iterator iterator()
          Return an Iterator over Trees in the Treebank.
 void loadPath(File path)
          Load a sequence of trees from given directory and its subdirectories.
abstract  void loadPath(File path, FileFilter filt)
          Load trees from given path specification.
 void loadPath(File path, String suffix, boolean recursively)
          Load trees from given directory.
 void loadPath(String pathName)
          Load a sequence of trees from given directory and its subdirectories.
 void loadPath(String pathName, FileFilter filt)
          Load a sequence of trees from given directory and its subdirectories which match the file filter.
 void loadPath(String pathName, String suffix, boolean recursively)
          Load trees from given directory.
 boolean remove(Object o)
          This operation isn't supported for a Treebank.
 int size()
          Returns the size of the Treebank.
 String toString()
          Return the whole treebank as a series of big bracketed lists.
protected  TreeReaderFactory treeReaderFactory()
          Get the TreeReaderFactory for a Treebank -- this method is provided in order to make the TreeReaderFactory available to subclasses.
 
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

Treebank

public Treebank()
Create a new Treebank (using a SimpleTreeReaderFactory).


Treebank

public Treebank(TreeReaderFactory trf)
Create a new Treebank.

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

Treebank

public Treebank(int initialCapacity)
Create a new Treebank.

Parameters:
initialCapacity - The initial size of the underlying Collection, (if a Collection-based storage mechanism is being provided)

Treebank

public Treebank(int initialCapacity,
                TreeReaderFactory trf)
Create a new Treebank.

Parameters:
initialCapacity - The initial size of the underlying Collection, (if a Collection-based storage mechanism is being provided)
trf - the factory class to be called to create a new TreeReader
Method Detail

treeReaderFactory

protected TreeReaderFactory treeReaderFactory()
Get the TreeReaderFactory for a Treebank -- this method is provided in order to make the TreeReaderFactory available to subclasses.

Returns:
The TreeReaderFactory

clear

public abstract void clear()
Empty a Treebank.

Specified by:
clear in interface Collection
Overrides:
clear in class AbstractCollection

loadPath

public void loadPath(String pathName)
Load a sequence of trees from given directory and its subdirectories. Trees should reside in files with the suffix "mrg". Or: load a single file with the given pathName (including extension)

Parameters:
pathName - file or directory name

loadPath

public void loadPath(File path)
Load a sequence of trees from given directory and its subdirectories. Trees should reside in files with the suffix "mrg".

Parameters:
path - File specification

loadPath

public void loadPath(String pathName,
                     String suffix,
                     boolean recursively)
Load trees from given directory.

Parameters:
pathName - file or directory name
suffix - suffix of files to load
recursively - descend into subdirectories as well

loadPath

public void loadPath(File path,
                     String suffix,
                     boolean recursively)
Load trees from given directory.

Parameters:
path - file or directory to load from
suffix - suffix of files to load
recursively - descend into subdirectories as well

loadPath

public void loadPath(String pathName,
                     FileFilter filt)
Load a sequence of trees from given directory and its subdirectories which match the file filter. Or: load a single file with the given pathName (including extension)

Parameters:
pathName - file or directory name
filt - A filter used to determine which files match

loadPath

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

Parameters:
path - file or directory to load from
filt - a FilenameFilter of files to load

iterator

public abstract Iterator iterator()
Return an Iterator over Trees in the Treebank.

Specified by:
iterator in interface Collection
Specified by:
iterator in class AbstractCollection
Returns:
The Iterator

apply

public abstract void apply(TreeProcessor tp)
Apply a TreeProcessor to each tree in the Treebank. For all current implementations of Treebank, this is the fastest way to traverse all the trees in the Treebank.

Parameters:
tp - The TreeProcessor to be applied

toString

public String toString()
Return the whole treebank as a series of big bracketed lists. Calling this is a really bad idea if your treebank is large.

Overrides:
toString in class AbstractCollection

size

public int size()
Returns the size of the Treebank.

Specified by:
size in interface Collection
Specified by:
size in class AbstractCollection
Returns:
size How many trees are in the treebank

remove

public boolean remove(Object o)
This operation isn't supported for a Treebank. Tell them immediately.

Specified by:
remove in interface Collection
Overrides:
remove in class AbstractCollection


Stanford NLP Group