edu.stanford.nlp.trees
Class MemorySentencebank

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

public final class MemorySentencebank
extends Sentencebank
implements FileProcessor

A MemorySentencebank object stores a corpus of examples with given sentence structures in memory (as a Collection)


Constructor Summary
MemorySentencebank()
          Create a new sentence bank.
MemorySentencebank(int initialCapacity)
          Create a new Sentencebank.
MemorySentencebank(int initialCapacity, SentenceReaderFactory srf)
          Create a new sentence bank.
MemorySentencebank(SentenceReaderFactory srf)
          Create a new sentence bank.
 
Method Summary
 void apply(SentenceProcessor sp)
          Apply the SentenceProcessor sp to all sentences in the Sentencebank
 void clear()
          Empty a Sentencebank.
 Object get(int i)
          Get a sentence by index from the Sentencebank.
 Iterator iterator()
          Return an Iterator over Sentences in the Sentencebank
 void loadPath(File path, FileFilter filt)
          Load sentences from given directory.
static void main(String[] args)
          Loads sentencebank grammar from first argument and print it.
 void processFile(File file)
          Load a collection of parse sentences from the file of given name.
 int size()
          Returns the size of the Sentencebank.
 
Methods inherited from class edu.stanford.nlp.trees.Sentencebank
loadPath, loadPath, loadPath, remove, sentenceReaderFactory, toString
 
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

MemorySentencebank

public MemorySentencebank()
Create a new sentence bank.


MemorySentencebank

public MemorySentencebank(SentenceReaderFactory srf)
Create a new sentence bank.

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

MemorySentencebank

public MemorySentencebank(int initialCapacity)
Create a new Sentencebank.

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

MemorySentencebank

public MemorySentencebank(int initialCapacity,
                          SentenceReaderFactory srf)
Create a new sentence bank.

Parameters:
initialCapacity - The initial size of the underlying Collection
srf - the factory class to be called to create a new SentenceReader
Method Detail

clear

public void clear()
Empty a Sentencebank.

Specified by:
clear in interface Collection
Specified by:
clear in class Sentencebank

loadPath

public void loadPath(File path,
                     FileFilter filt)
Load sentences from given directory.

Specified by:
loadPath in class Sentencebank
Parameters:
path - file or directory to load from

processFile

public void processFile(File file)
Load a collection of parse sentences from the file of given name. Each sentence may optionally be encased in parens to allow for Penn Sentencebank style sentences. This methods implements the FileProcessor interface.

Specified by:
processFile in interface FileProcessor
Parameters:
file - file to load a sentence from
See Also:
for traversing directories

get

public Object get(int i)
Get a sentence by index from the Sentencebank.


apply

public void apply(SentenceProcessor sp)
Apply the SentenceProcessor sp to all sentences in the Sentencebank

Specified by:
apply in class Sentencebank
Parameters:
sp - The SentenceProcessor to be applied

iterator

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

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

size

public int size()
Returns the size of the Sentencebank. Provides a more efficient implementation than the one for a generic Sentencebank

Specified by:
size in interface Collection
Overrides:
size in class Sentencebank
Returns:
the number of trees in the Sentencebank

main

public static void main(String[] args)
Loads sentencebank grammar from first argument and print it.

Parameters:
args - array of command-line arguments


Stanford NLP Group