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>
The
CrossValidationPartitioner.TrainingSampleStream
which iterates over
all training elements.
Note:
After the CrossValidationPartitioner.TestSampleStream
was obtained
the CrossValidationPartitioner.TrainingSampleStream
must not be used
anymore, otherwise a IllegalStateException
is thrown.
The streams
must not be used anymore after the
CrossValidationPartitioner
was moved to one of next partitions.
If they are called anyway an IllegalStateException
is thrown.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes theObjectStream
and releases all allocated resources.Retrieves theObjectStream
over the test/evaluations elements and poisons thisCrossValidationPartitioner.TrainingSampleStream
.read()
Returns the nextObjectStream
object.void
reset()
Resets the training sample.
-
Method Details
-
read
Description copied from interface:ObjectStream
Returns the nextObjectStream
object. Calling this method repeatedly until it returnsnull
will return each object from the underlying source exactly once.- Specified by:
read
in interfaceObjectStream<E>
- Returns:
- The next object or
null
to signal that the stream is exhausted. - Throws:
IOException
- Thrown if there is an error during reading.
-
reset
Resets 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:
reset
in interfaceObjectStream<E>
- Throws:
IOException
- Thrown if IO errors occurred.IllegalStateException
- Thrown if a non-consistent state occurred.
-
close
Description copied from interface:ObjectStream
Closes theObjectStream
and releases all allocated resources. After close was called, it's not allowed to callObjectStream.read()
orObjectStream.reset()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceObjectStream<E>
- Throws:
IOException
- Thrown if there is an error during closing the stream.
-
getTestSampleStream
Retrieves theObjectStream
over 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
-