com.aliasi.corpus
Class Corpus<H extends Handler>

java.lang.Object
  extended by com.aliasi.corpus.Corpus<H>
Type Parameters:
H - the type of handler to which this corpus sends events
Direct Known Subclasses:
DiskCorpus, ListCorpus, XValidatingClassificationCorpus, XValidatingObjectCorpus

public class Corpus<H extends Handler>
extends Object

The Corpus abstract class provides a basis for passing training and testing data to data handlers. The methods walk handlers over the training and/or test data, depending on which of the methods is called.

Since:
LingPipe2.3
Version:
3.0
Author:
Bob Carpenter

Constructor Summary
protected Corpus()
          Construct a corpus.
 
Method Summary
 void visitCorpus(H handler)
          Visit the entire corpus, sending all extracted events to the specified handler.
 void visitCorpus(H trainHandler, H testHandler)
          Visit the entire corpus, first sending training events to the specified training handler and then sending testing events to the test handler.
 void visitTest(H handler)
          Visit the testing section of the corpus, sending events to the specified handler.
 void visitTrain(H handler)
          Visit the training section of the corpus, sending events to the specified handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Corpus

protected Corpus()
Construct a corpus.

Method Detail

visitCorpus

public void visitCorpus(H handler)
                 throws IOException
Visit the entire corpus, sending all extracted events to the specified handler.

This is just a convenience method that is defined by:

 visitCorpus(handler,handler);
 

Parameters:
handler - Handler for events extracted from the corpus.
Throws:
IOException - If there is an underlying I/O error.

visitCorpus

public void visitCorpus(H trainHandler,
                        H testHandler)
                 throws IOException
Visit the entire corpus, first sending training events to the specified training handler and then sending testing events to the test handler.

This is just a convenience method that is defined by:

 visitTrain(trainHandler);
 visitTest(testHandler);
 

Parameters:
trainHandler - Handler for training events from the corpus.
testHandler - Handler for testing events from the corpus.
Throws:
IOException - If there is an underlying I/O error.

visitTrain

public void visitTrain(H handler)
                throws IOException
Visit the training section of the corpus, sending events to the specified handler.

The implementation does nothing. This method should be overridden by subclasses that contain training data.

Parameters:
handler - Handler for training events.
Throws:
IOException - If there is an underlying I/O error.

visitTest

public void visitTest(H handler)
               throws IOException
Visit the testing section of the corpus, sending events to the specified handler.

The implementation does nothing. This method should be overridden by subclasses that contain test data.

Parameters:
handler - Handler for training events.
Throws:
IOException - If there is an underlying I/O error.