Class DependencyEventStream

java.lang.Object
opennlp.tools.depparse.DependencyEventStream
All Implemented Interfaces:
AutoCloseable, ObjectStream<Event>

class DependencyEventStream extends Object implements ObjectStream<Event>
Turns samples into training events: for each sample the ArcStandardOracle derives the gold transitions, and every transition becomes one event pairing the configuration features with the encoded transition.

Samples whose tree has no arc-standard derivation, that is non-projective trees, are skipped and counted; the count is logged once the stream is exhausted.

  • Field Details

  • Constructor Details

  • Method Details

    • read

      public Event read() throws IOException
      Returns the next ObjectStream object. Calling this method repeatedly until it returns null will return each object from the underlying source exactly once.

      Returns the events of one sample at a time and moves on to the next sample once they are exhausted.

      Specified by:
      read in interface ObjectStream<Event>
      Returns:
      The next object or null to signal that the stream is exhausted.
      Throws:
      IOException - Thrown if reading the underlying samples fails.
    • reset

      public void reset() throws IOException, UnsupportedOperationException
      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.

      Also discards buffered events and the skipped sample count.

      Specified by:
      reset in interface ObjectStream<Event>
      Throws:
      IOException - Thrown if resetting the underlying samples fails.
      UnsupportedOperationException - Thrown if the underlying samples cannot be reset.
    • close

      public void close() throws IOException
      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<Event>
      Throws:
      IOException - Thrown if closing the underlying samples fails.