Package opennlp.tools.ml.model

# Class FileEventStream

java.lang.Object
opennlp.tools.ml.model.FileEventStream

All Implemented Interfaces:
  `AutoCloseable`, `opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>`

Direct Known Subclasses:
  `RealValueFileEventStream`

public class FileEventStream extends Object implements opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>
Class for using a file of `events` as an `event stream`. The format of the file is one event per line with each line consisting of outcome followed by contexts (space delimited).

See Also:
  - `Event`
  - `ObjectStream`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FileEventStream(File file)`
  Instantiates a `FileEventStream` via a `File`.
  `FileEventStream(Reader reader)`
  Instantiates a `FileEventStream` via a `Reader`.
  `FileEventStream(String fileName)`
  Instantiates a `FileEventStream` from the specified file name.
  `FileEventStream(String fileName, String encoding)`
  Instantiates a `FileEventStream` from the specified file name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `opennlp.tools.ml.model.Event`
  `read()`
  Returns the next `Event` object.
  `void`
  `reset()`
  `static String`
  `toLine(opennlp.tools.ml.model.Event event)`
  Generates a string representing the specified event.

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

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

- ## Constructor Details

  - ### FileEventStream

    public FileEventStream(String fileName, String encoding) throws IOException
    Instantiates a `FileEventStream` from the specified file name.
    Parameters:
      `fileName` - The name fo the file containing the events.
      `encoding` - The name of the `character encoding`.
    Throws:
      `IOException` - Thrown if the specified file can not be read.

  - ### FileEventStream

    public FileEventStream(String fileName) throws IOException
    Instantiates a `FileEventStream` from the specified file name.
    Parameters:
      `fileName` - The name fo the file containing the events.
    Throws:
      `IOException` - Thrown if the specified file can not be read.

  - ### FileEventStream

    public FileEventStream(Reader reader) throws IOException
    Instantiates a `FileEventStream` via a `Reader`.
    Parameters:
      `reader` - The `Reader` that holds events.
    Throws:
      `IOException` - Thrown if the specified file can not be read.

  - ### FileEventStream

    public FileEventStream(File file) throws IOException
    Instantiates a `FileEventStream` via a `File`.
    Parameters:
      `file` - The `File` that holds events.
    Throws:
      `IOException` - Thrown if the specified file can not be read.

- ## Method Details

  - ### read

    public opennlp.tools.ml.model.Event read() throws IOException
    Returns the next `Event` object. Calling this method repeatedly until it returns `null` will return each object from the underlying source exactly once.
    Specified by:
      `read` in interface `opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>`
    Returns:
      The next object or `null` to signal that the stream is exhausted.
    Throws:
      `IOException` - Thrown if there is an error during reading.

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>`
    Throws:
      `IOException`

  - ### toLine

    public static String toLine(opennlp.tools.ml.model.Event event)
    Generates a string representing the specified event.
    Parameters:
      `event` - The `Event` for which a string representation is needed.
    Returns:
      A string representing the specified event.

  - ### reset

    public void reset() throws IOException, UnsupportedOperationException
    Specified by:
      `reset` in interface `opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>`
    Throws:
      `IOException`
      `UnsupportedOperationException`