Package opennlp.tools.formats.masc

## Class MascNamedEntitySampleStream

- java.lang.Object
- - opennlp.tools.util.FilterObjectStream<MascDocument,​NameSample>
  - - opennlp.tools.formats.masc.MascNamedEntitySampleStream

- All Implemented Interfaces:
    `AutoCloseable`, `ObjectStream<NameSample>`

      public class MascNamedEntitySampleStream
      extends FilterObjectStream<MascDocument,​NameSample>

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MascNamedEntitySampleStream​(ObjectStream<MascDocument> samples)` | Initializes `MascNamedEntitySampleStream` from a stream of `documents`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Closes the `ObjectStream` and releases all allocated resources.
    `NameSample` | `read()` | Reads the next sample of named entities.
    `void` | `reset()` | Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.

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

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

- - ### Constructor Detail

    - #### MascNamedEntitySampleStream

          public MascNamedEntitySampleStream​(ObjectStream<MascDocument> samples)
                                      throws IOException

      Initializes `MascNamedEntitySampleStream` from a stream of `documents`.
      Parameters:
        `samples` - A `ObjectStream` of samples.
      Throws:
        `IOException` - Thrown if none of the documents has NE labels.

  - ### Method Detail

    - #### read

          public NameSample read()
                          throws IOException

      Reads the next sample of named entities.
      Returns:
        One `sentence together with its named entity annotation`.
      Throws:
        `IOException` - Thrown if the sample cannot be extracted

    - #### close

          public void close()
                     throws IOException

      Description copied from interface: `ObjectStream`
      Closes the `ObjectStream` and releases all allocated resources. After close was called, it's not allowed to call `ObjectStream.read()` or `ObjectStream.reset()`.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `ObjectStream<NameSample>`
      Overrides:
        `close` in class `FilterObjectStream<MascDocument,​NameSample>`
      Throws:
        `IOException` - Thrown if there is an error during closing the stream.

    - #### reset

          public void reset()
                     throws IOException,
                            UnsupportedOperationException

      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 interface `ObjectStream<NameSample>`
      Overrides:
        `reset` in class `FilterObjectStream<MascDocument,​NameSample>`
      Throws:
        `IOException` - Thrown if there is an error during resetting the stream.
        `UnsupportedOperationException` - Thrown if the `reset()` is not supported. By default, this is the case.