edu.stanford.nlp.trees
Class Sentencebank

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--edu.stanford.nlp.trees.Sentencebank
All Implemented Interfaces:
Collection
Direct Known Subclasses:
DiskSentencebank, MemorySentencebank

public abstract class Sentencebank
extends AbstractCollection
implements Collection

A Sentencebank object provides access to a corpus of sentences -- just plain sentences or tagged sentences, etc. This class implements the Collection interface, but in a read-only way.


Constructor Summary
Sentencebank()
          Create a new Sentencebank.
Sentencebank(int initialCapacity)
          Create a new Sentencebank.
Sentencebank(int initialCapacity, SentenceReaderFactory srf)
          Create a new Sentencebank.
Sentencebank(SentenceReaderFactory srf)
          Create a new Sentencebank.
 
Method Summary
abstract  void apply(SentenceProcessor tp)
          Apply a SentenceProcessor to each tree in the Sentencebank
abstract  void clear()
          Empty a Sentencebank.
abstract  Iterator iterator()
          Return an Iterator over Sentences in the Sentencebank
 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.
 boolean remove(Object o)
          This operation isn't supported for a Sentencebank.
protected  SentenceReaderFactory sentenceReaderFactory()
          Get the SentenceReaderFactory for a Sentencebank -- this method is provided in order to make the SentenceReaderFactory available to subclasses.
 int size()
          Returns the size of the Sentencebank.
 String toString()
          Return the whole treebank as a series of big bracketed lists.
 
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
add, addAll, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

Sentencebank

public Sentencebank()
Create a new Sentencebank.


Sentencebank

public Sentencebank(SentenceReaderFactory srf)
Create a new Sentencebank.

Parameters:
srf - the factory class to be called to create a new SentenceReader

Sentencebank

public Sentencebank(int initialCapacity)
Create a new Sentencebank.

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

Sentencebank

public Sentencebank(int initialCapacity,
                    SentenceReaderFactory srf)
Create a new Sentencebank.

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

sentenceReaderFactory

protected SentenceReaderFactory sentenceReaderFactory()
Get the SentenceReaderFactory for a Sentencebank -- this method is provided in order to make the SentenceReaderFactory available to subclasses.


clear

public abstract void clear()
Empty a Sentencebank.

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. Sentences should reside in files with the suffix "pos". 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. Sentences should reside in files with the suffix "pos".

Parameters:
path - File specification

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 abstract void loadPath(File path,
                              FileFilter filt)
Load trees from given path specification

Parameters:
path - file or directory to load from

apply

public abstract void apply(SentenceProcessor tp)
Apply a SentenceProcessor to each tree in the Sentencebank

Parameters:
tp - The SentenceProcessor to be applied

iterator

public abstract Iterator iterator()
Return an Iterator over Sentences in the Sentencebank

Specified by:
iterator in interface Collection
Specified by:
iterator in class AbstractCollection

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 Sentencebank.

Specified by:
size in interface Collection
Specified by:
size in class AbstractCollection

remove

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

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


Stanford NLP Group