Package opennlp.tools.util.eval
Class CrossValidationPartitioner.TrainingSampleStream<E>
- java.lang.Object
-
- opennlp.tools.util.eval.CrossValidationPartitioner.TrainingSampleStream<E>
-
- Type Parameters:
E- The generic type of samples.
- All Implemented Interfaces:
AutoCloseable,ObjectStream<E>
- Enclosing class:
- CrossValidationPartitioner<E>
public static class CrossValidationPartitioner.TrainingSampleStream<E> extends Object implements ObjectStream<E>
TheCrossValidationPartitioner.TrainingSampleStreamwhich iterates over all training elements.Note: After the
CrossValidationPartitioner.TestSampleStreamwas obtained theCrossValidationPartitioner.TrainingSampleStreammust not be used anymore, otherwise aIllegalStateExceptionis thrown.The
streamsmust not be used anymore after theCrossValidationPartitionerwas moved to one of next partitions. If they are called anyway anIllegalStateExceptionis thrown.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes theObjectStreamand releases all allocated resources.ObjectStream<E>getTestSampleStream()Retrieves theObjectStreamover the test/evaluations elements and poisons thisCrossValidationPartitioner.TrainingSampleStream.Eread()Returns the nextObjectStreamobject.voidreset()Resets the training sample.
-
-
-
Method Detail
-
read
public E read() throws IOException
Description copied from interface:ObjectStreamReturns the nextObjectStreamobject. Calling this method repeatedly until it returnsnullwill return each object from the underlying source exactly once.- Specified by:
readin interfaceObjectStream<E>- Returns:
- The next object or
nullto signal that the stream is exhausted. - Throws:
IOException- Thrown if there is an error during reading.
-
reset
public void reset() throws IOExceptionResets the training sample. Use this if you need to collect things before training, for example, to collect induced abbreviations or create a POS Dictionary.- Specified by:
resetin interfaceObjectStream<E>- Throws:
IOException- Thrown if IO errors occurred.IllegalStateException- Thrown if a non-consistent state occurred.
-
close
public void close() throws IOExceptionDescription copied from interface:ObjectStreamCloses theObjectStreamand releases all allocated resources. After close was called, it's not allowed to callObjectStream.read()orObjectStream.reset().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceObjectStream<E>- Throws:
IOException- Thrown if there is an error during closing the stream.
-
getTestSampleStream
public ObjectStream<E> getTestSampleStream() throws IOException
Retrieves theObjectStreamover the test/evaluations elements and poisons thisCrossValidationPartitioner.TrainingSampleStream. From now on calls to the hasNext and next methods are forbidden and will raise anIllegalArgumentException.- Returns:
- The test sample
stream. - Throws:
IOException
-
-