com.aliasi.corpus
Class ListCorpus<E>

java.lang.Object
  extended by com.aliasi.corpus.Corpus<ObjectHandler<E>>
      extended by com.aliasi.corpus.ListCorpus<E>
Type Parameters:
E - the type of objects handled in the corpus.
All Implemented Interfaces:
Serializable

public class ListCorpus<E>
extends Corpus<ObjectHandler<E>>
implements Serializable

A ListCorpus implements a corpus based on a list of training and test cases. Training and testing cases are added to the corpus with addTrain(Object) and addTest(Object) respectively. The training and test data may be randomized using permuteCorpus(Random).

Serialization

A list corpus is serializable if all of the training and test objects are serializable. The deserialized object will also be a list corpus.

Thread Safety

A list corpus must be concurrent read/synchronous write synchronized. The two writer operations are the methods that add cases.

Since:
LingPipe3.9.2
Version:
3.9.2
Author:
Bob Carpenter
See Also:
Serialized Form

Constructor Summary
ListCorpus()
          Construct a list-based corpus with no entries.
 
Method Summary
 void addTest(E e)
          Add the specified item to the list of test items.
 void addTrain(E e)
          Add the specified item to the list of training items.
 void permuteCorpus(Random random)
          Uses the specified random number generator to permute the training and test cases in the corpus.
 void visitTest(ObjectHandler<E> handler)
          Visit the testing section of the corpus, sending events to the specified handler.
 void visitTrain(ObjectHandler<E> handler)
          Visit the training section of the corpus, sending events to the specified handler.
 
Methods inherited from class com.aliasi.corpus.Corpus
visitCorpus, visitCorpus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListCorpus

public ListCorpus()
Construct a list-based corpus with no entries.

Method Detail

addTest

public void addTest(E e)
Add the specified item to the list of test items.

Parameters:
e - Item to add as test case.

addTrain

public void addTrain(E e)
Add the specified item to the list of training items.

Parameters:
e - Item to add as training case.

permuteCorpus

public void permuteCorpus(Random random)
Uses the specified random number generator to permute the training and test cases in the corpus. Using the same randomizer will produce the same result.

Parameters:
random - Randomizer for corpus.

visitTrain

public void visitTrain(ObjectHandler<E> handler)
Description copied from class: Corpus
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.

Overrides:
visitTrain in class Corpus<ObjectHandler<E>>
Parameters:
handler - Handler for training events.

visitTest

public void visitTest(ObjectHandler<E> handler)
Description copied from class: Corpus
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.

Overrides:
visitTest in class Corpus<ObjectHandler<E>>
Parameters:
handler - Handler for training events.