Package opennlp.tools.ml.model

# Class RealValueFileEventStream

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

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

public class RealValueFileEventStream extends FileEventStream
Class for using a file of real-valued `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`
  - `FileEventStream`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static float[]`
  `parseContexts(String[] contexts)`
  Parses the specified `contexts` and re-populates context array with features and returns the values for these features.
  `opennlp.tools.ml.model.Event`
  `read()`
  Returns the next `Event` object.

  ### Methods inherited from class opennlp.tools.ml.model.FileEventStream

  `close, reset, toLine`

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

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

- ## Constructor Details

  - ### RealValueFileEventStream

    public RealValueFileEventStream(String fileName) throws IOException
    Instantiates a `RealValueFileEventStream` 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.

  - ### RealValueFileEventStream

    public RealValueFileEventStream(String fileName, String encoding) throws IOException
    Instantiates a `RealValueFileEventStream` 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.

  - ### RealValueFileEventStream

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

  - ### RealValueFileEventStream

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

- ## Method Details

  - ### parseContexts

    public static float[] parseContexts(String[] contexts)
    Parses the specified `contexts` and re-populates context array with features and returns the values for these features. If all values are unspecified, then `null` is returned.
    Parameters:
      `contexts` - The contexts with real values specified.
    Returns:
      The value for each context or `null` if all values are unspecified.
    Throws:
      `RuntimeException` - Thrown if negative real values are detected in the input data.

  - ### 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>`
    Overrides:
      `read` in class `FileEventStream`
    Returns:
      The next object or `null` to signal that the stream is exhausted.
    Throws:
      `IOException` - Thrown if there is an error during reading.
      `RuntimeException` - Thrown if negative real values are detected in the input data.