Package opennlp.tools.util.eval
Class CrossValidationPartitioner.TrainingSampleStream<E>
- java.lang.Object
-
- opennlp.tools.util.eval.CrossValidationPartitioner.TrainingSampleStream<E>
-
- Type Parameters:
E
-
- All Implemented Interfaces:
AutoCloseable
,ObjectStream<E>
- Enclosing class:
- CrossValidationPartitioner<E>
public static class CrossValidationPartitioner.TrainingSampleStream<E> extends Object implements ObjectStream<E>
TheTrainingSampleStream
which iterates over all training elements. Note: After theTestSampleStream
was obtained theTrainingSampleStream
must not be used anymore, otherwise aIllegalStateException
is thrown. TheObjectStream
s must not be used anymore after theCrossValidationPartitioner
was moved to one of next partitions. If they are called anyway aIllegalStateException
is thrown.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes theObjectStream
and releases all allocated resources.ObjectStream<E>
getTestSampleStream()
Retrieves theObjectStream
over the test/evaluations elements and poisons thisTrainingSampleStream
.E
read()
Returns the next object.void
reset()
Resets the training sample.
-
-
-
Method Detail
-
read
public E read() throws IOException
Description copied from interface:ObjectStream
Returns the next object. Calling this method repeatedly until it returns null 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
- if there is an error during reading
-
reset
public void reset() throws IOException
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
-
close
public void close() throws IOException
Description copied from interface:ObjectStream
Closes theObjectStream
and releases all allocated resources. After close was called its not allowed to call read or reset.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceObjectStream<E>
- Throws:
IOException
- if there is an error during closing the stream
-
getTestSampleStream
public ObjectStream<E> getTestSampleStream() throws IOException
Retrieves theObjectStream
over the test/evaluations elements and poisons thisTrainingSampleStream
. From now on calls to the hasNext and next methods are forbidden and will raise anIllegalArgumentException
.- Returns:
- the test sample stream
- Throws:
IOException
-
-