edu.stanford.nlp.trees
Class Sentencebank

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byedu.stanford.nlp.trees.Sentencebank
All Implemented Interfaces:
Collection
Direct Known Subclasses:
DiskSentencebank, MemorySentencebank

public abstract class Sentencebank
extends AbstractCollection

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. A typical way of creating and using a Sentencebank looks like:

 SentenceReaderFactory srf = new AdwaitSentenceReaderFactory(true);
 Sentencebank sb1 = new DiskSentencebank(srf);
 sb1.loadPath(inputFile);

 for (Iterator i1 = sb1.iterator(); i1.hasNext(); ) {
     Sentence s1 = (Sentence) i1.next();
     System.out.println(s1);
 }
 

Author:
Christopher Manning

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(SentenceVisitor tp)
          Apply a SentenceVisitor to each sentence 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 sentences from given directory and its subdirectories.
abstract  void loadPath(File path, FileFilter filt)
          Load sentences from given path specification.
 void loadPath(File path, String suffix, boolean recursively)
          Load sentences from given directory.
 void loadPath(String pathName)
          Load a sequence of sentences from the 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 Sentencebank 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
equals, hashCode
 

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.


loadPath

public void loadPath(String pathName)
Load a sequence of sentences from the 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 sentences 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 sentences 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 sentences from given path specification.

Parameters:
path - file or directory to load from

apply

public abstract void apply(SentenceVisitor tp)
Apply a SentenceVisitor to each sentence in the Sentencebank.

Parameters:
tp - The SentenceVisitor to be applied

iterator

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


toString

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


size

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


remove

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

Parameters:
o - The object that would be removed


Stanford NLP Group