Package opennlp.tools.formats.masc
Class MascPOSSampleStream
java.lang.Object
opennlp.tools.util.FilterObjectStream<MascDocument,POSSample>
opennlp.tools.formats.masc.MascPOSSampleStream
- All Implemented Interfaces:
AutoCloseable
,ObjectStream<POSSample>
-
Constructor Summary
ConstructorDescriptionMascPOSSampleStream
(ObjectStream<MascDocument> samples) InitializesMascPOSSampleStream
from a stream ofdocuments
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes theObjectStream
and releases all allocated resources.read()
Reads the next sample.void
reset()
Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
-
Constructor Details
-
MascPOSSampleStream
InitializesMascPOSSampleStream
from a stream ofdocuments
.- Parameters:
samples
- AObjectStream<MascDocument>
of samples.- Throws:
IOException
- Thrown if none of the documents has POS tags.
-
-
Method Details
-
read
Reads the next sample.- Returns:
- One
sentence together with its POS tags
. - Throws:
IOException
- Thrown if the sample cannot be extracted.
-
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<POSSample>
- Overrides:
close
in classFilterObjectStream<MascDocument,
POSSample> - Throws:
IOException
- Thrown if there is an error during closing the stream.
-
reset
Description copied from interface:ObjectStream
Repositions 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:
reset
in interfaceObjectStream<POSSample>
- Overrides:
reset
in classFilterObjectStream<MascDocument,
POSSample> - 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.
-