edu.stanford.nlp.trees
Class DiskSentencebank

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

public final class DiskSentencebank
extends Sentencebank

A DiskSentencebank object stores merely the information to get at a corpus of sentences that is stored on disk. Access is usually via applying a SentenceProcessor to an iteration over the sentences.


Constructor Summary
DiskSentencebank()
          Create a new DiskSentencebank.
DiskSentencebank(int initialCapacity)
          Create a new Sentencebank.
DiskSentencebank(int initialCapacity, SentenceReaderFactory srf)
          Create a new Sentencebank.
DiskSentencebank(SentenceReaderFactory srf)
          Create a new DiskSentencebank.
 
Method Summary
 void apply(SentenceProcessor sp)
          Applies the SentenceProcessor to to all trees in the Sentencebank.
 void clear()
          Empty a Sentencebank.
 File getCurrentFile()
          Return the File from which trees are currently being read by apply(), and pased to a SentencePprocessor.
 Iterator iterator()
          Return an Iterator over Sentences in the Sentencebank.
 void loadPath(File path, FileFilter filt)
          Load trees from given directory.
static void main(String[] args)
          Loads SentenceBank from first argument and prints it out.
 
Methods inherited from class edu.stanford.nlp.trees.Sentencebank
loadPath, loadPath, loadPath, remove, sentenceReaderFactory, size, 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

DiskSentencebank

public DiskSentencebank()
Create a new DiskSentencebank.


DiskSentencebank

public DiskSentencebank(SentenceReaderFactory srf)
Create a new DiskSentencebank.

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

DiskSentencebank

public DiskSentencebank(int initialCapacity)
Create a new Sentencebank.

Parameters:
initialCapacity - The initial size of the underlying Collection. For a DiskSentencebank, this parameter is ignored.

DiskSentencebank

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

Parameters:
initialCapacity - The initial size of the underlying Collection, For a DiskSentencebank, this parameter is ignored.
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 trees from given directory. This version just records the paths to be processed, and actually processes them at apply time.

Specified by:
loadPath in class Sentencebank
Parameters:
path - file or directory to load from
filt - a FilenameFilter of files to load

apply

public void apply(SentenceProcessor sp)
Applies the SentenceProcessor to to all trees in the Sentencebank.

Specified by:
apply in class Sentencebank
Parameters:
sp - A class that can process trees.

getCurrentFile

public File getCurrentFile()
Return the File from which trees are currently being read by apply(), and pased to a SentencePprocessor. This is useful if one wants to map the original file and directory structure over to a set of modified trees.

Returns:
the file that trees are currently being read from, or null if no file is currently open

iterator

public Iterator iterator()
Return an Iterator over Sentences in the Sentencebank. This is implemented by building per-file MemorySentencebanks for the files in the DiskSentencebank. As such, it isn't as efficient as using apply().

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

main

public static void main(String[] args)
Loads SentenceBank from first argument and prints it out.
Usage: java edu.stanford.nlp.trees.DiskSentencebank [-n|-w] sentencebankPath [low high]

Parameters:
args - Array of command-line arguments


Stanford NLP Group