Package opennlp.tools.formats.ad
Class ADSentenceSampleStream
- java.lang.Object
-
- opennlp.tools.formats.ad.ADSentenceSampleStream
-
- All Implemented Interfaces:
AutoCloseable,ObjectStream<SentenceSample>
public class ADSentenceSampleStream extends Object implements ObjectStream<SentenceSample>
Note: Do not use this class, internal use only!
-
-
Constructor Summary
Constructors Constructor Description ADSentenceSampleStream(InputStreamFactory in, String charsetName, boolean includeHeadlines)Creates a newSentenceSamplestream from aFileInputStreamADSentenceSampleStream(ObjectStream<String> lineStream, boolean includeHeadlines)Creates a newSentenceSamplestream from a line stream, i.e.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes theObjectStreamand releases all allocated resources.SentenceSampleread()Returns the next object.voidreset()Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
-
-
-
Constructor Detail
-
ADSentenceSampleStream
public ADSentenceSampleStream(ObjectStream<String> lineStream, boolean includeHeadlines)
Creates a newSentenceSamplestream from a line stream, i.e.ObjectStream<String>, that could be aPlainTextByLineStreamobject.- Parameters:
lineStream- a stream of lines asStringincludeHeadlines- if true will output the sentences marked as news headlines
-
ADSentenceSampleStream
public ADSentenceSampleStream(InputStreamFactory in, String charsetName, boolean includeHeadlines) throws IOException
Creates a newSentenceSamplestream from aFileInputStream- Parameters:
in- input stream from the corpuscharsetName- the charset to use while reading the corpusincludeHeadlines- if true will output the sentences marked as news headlines- Throws:
IOException
-
-
Method Detail
-
read
public SentenceSample read() throws IOException
Description copied from interface:ObjectStreamReturns the next object. Calling this method repeatedly until it returns null will return each object from the underlying source exactly once.- Specified by:
readin interfaceObjectStream<SentenceSample>- 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, 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<SentenceSample>- Throws:
IOException- if there is an error during reseting the streamUnsupportedOperationException
-
close
public void close() throws IOExceptionDescription copied from interface:ObjectStreamCloses theObjectStreamand releases all allocated resources. After close was called its not allowed to call read or reset.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceObjectStream<SentenceSample>- Throws:
IOException- if there is an error during closing the stream
-
-