Package opennlp.tools.stopword

# Class StopwordFilterStream

java.lang.Object
opennlp.tools.util.FilterObjectStream<String[],String[]>
opennlp.tools.stopword.StopwordFilterStream

All Implemented Interfaces:
  `AutoCloseable`, `opennlp.tools.util.ObjectStream<String[]>`

public final class StopwordFilterStream extends FilterObjectStream<String[],String[]>
A `FilterObjectStream` which removes stopwords from each `String[]` sample produced by an underlying `ObjectStream<String[]>`.

Stopword membership is decided by the supplied `StopwordFilter`; filtering is delegated to `StopwordFilter.filter(String[])` so the relative order of surviving tokens within a sample is preserved.

`FilterObjectStream.reset()` and `FilterObjectStream.close()` are inherited from `FilterObjectStream` and simply forward to the wrapped stream.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StopwordFilterStream(opennlp.tools.util.ObjectStream<String[]> samples, opennlp.tools.stopword.StopwordFilter filter)`
  Initializes a `StopwordFilterStream`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String[]`
  `read()`
  Reads the next sample from the wrapped stream and returns it with stopwords removed.

  ### 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

  - ### StopwordFilterStream

    public StopwordFilterStream(opennlp.tools.util.ObjectStream<String[]> samples, opennlp.tools.stopword.StopwordFilter filter)
    Initializes a `StopwordFilterStream`.
    Parameters:
      `samples` - The `ObjectStream` of token arrays to filter. Must not be `null`.
      `filter` - The `StopwordFilter` used to drop stopwords. Must not be `null`.
    Throws:
      `IllegalArgumentException` - if `samples` or `filter` is `null`.

- ## Method Details

  - ### read

    public String[] read() throws IOException
    Reads the next sample from the wrapped stream and returns it with stopwords removed. Returns `null` once the underlying stream is exhausted.
    Returns:
      The filtered sample or `null` at the end of the stream.
    Throws:
      `IOException` - If the underlying stream throws an I/O error.