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>
public class MascPOSSampleStream extends FilterObjectStream<MascDocument,POSSample>
-
-
Constructor Summary
Constructors Constructor Description MascPOSSampleStream(ObjectStream<MascDocument> samples)InitializesMascPOSSampleStreamfrom a stream ofdocuments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes theObjectStreamand releases all allocated resources.POSSampleread()Reads the next sample.voidreset()Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
-
-
-
Constructor Detail
-
MascPOSSampleStream
public MascPOSSampleStream(ObjectStream<MascDocument> samples) throws IOException
InitializesMascPOSSampleStreamfrom a stream ofdocuments.- Parameters:
samples- AObjectStreamof samples.- Throws:
IOException- Thrown if none of the documents has POS tags.
-
-
Method Detail
-
read
public POSSample read() throws IOException
Reads the next sample.- Returns:
- One
sentence together with its POS tags. - Throws:
IOException- Thrown if the sample cannot be extracted.
-
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<POSSample>- Overrides:
closein classFilterObjectStream<MascDocument,POSSample>- Throws:
IOException- Thrown if there is an error during closing the stream.
-
reset
public void reset() throws IOException, UnsupportedOperationExceptionDescription 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<POSSample>- Overrides:
resetin 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.
-
-