Package opennlp.tools.formats.masc
Class MascSentenceSampleStream
java.lang.Object
opennlp.tools.util.FilterObjectStream<MascDocument,SentenceSample>
opennlp.tools.formats.masc.MascSentenceSampleStream
- All Implemented Interfaces:
AutoCloseable,ObjectStream<SentenceSample>
-
Constructor Summary
ConstructorsConstructorDescriptionMascSentenceSampleStream(ObjectStream<MascDocument> samples, int sentencesPerSample) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes theObjectStreamand releases all allocated resources.read()Reads a newsample of sentences.voidreset()Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
-
Constructor Details
-
MascSentenceSampleStream
public MascSentenceSampleStream(ObjectStream<MascDocument> samples, int sentencesPerSample) throws IOException - Throws:
IOException
-
-
Method Details
-
read
Reads a newsample of sentences.- Returns:
- The
specified number of sentences. If fewer left, then return whatever is left. - Throws:
IOException- Thrown if IO errors occurred during read operation.
-
close
Description 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<SentenceSample>- Overrides:
closein classFilterObjectStream<MascDocument,SentenceSample> - Throws:
IOException- Thrown if there is an error during closing the stream.
-
reset
Description copied from interface:ObjectStreamRepositions the stream at the beginning and the previously seen object sequence will be repeated exactly. This method can be used to re-read the stream if multiple passes over the objects are required.The implementation of this method is optional.
- Specified by:
resetin interfaceObjectStream<SentenceSample>- Overrides:
resetin classFilterObjectStream<MascDocument,SentenceSample> - Throws:
IOException- Thrown if there is an error during resetting the stream.UnsupportedOperationException- Thrown if thereset()is not supported. By default, this is the case.
-