Package opennlp.tools.postag

# Class WordTagSampleStream

java.lang.Object
opennlp.tools.util.FilterObjectStream<String,opennlp.tools.postag.POSSample>
opennlp.tools.postag.WordTagSampleStream

All Implemented Interfaces:
  `AutoCloseable`, `opennlp.tools.util.ObjectStream<opennlp.tools.postag.POSSample>`

public class WordTagSampleStream extends FilterObjectStream<String,opennlp.tools.postag.POSSample>
A `stream filter` which reads a sentence per line that contains words and tags in `word_tag` format and outputs a `POSSample` objects.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WordTagSampleStream(opennlp.tools.util.ObjectStream<String> sentences)`
  Initializes a `POSSample` instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `opennlp.tools.postag.POSSample`
  `read()`
  Reads the next tokens and parses it into the next `POSSample` object.

  ### Methods inherited from class opennlp.tools.util.FilterObjectStream

  `close, reset`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### WordTagSampleStream

    public WordTagSampleStream(opennlp.tools.util.ObjectStream<String> sentences)
    Initializes a `POSSample` instance.
    Parameters:
      `sentences` - The `sentences` to wrap.

- ## Method Details

  - ### read

    public opennlp.tools.postag.POSSample read() throws IOException
    Reads the next tokens and parses it into the next `POSSample` object.

    If an error occurs an empty `POSSample` object is returned and a warning message is logged. Usually it does not matter if one or many sentences are ignored.

    Returns:
      A valid `POSSample` or `null` if the `stream` is exhausted.
    Throws:
      `IOException` - Thrown if IO errors occurred during read.