Class SimpleEventStreamBuilder

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

public class SimpleEventStreamBuilder extends Object
Builds an in-memory ObjectStream of events from text lines, mainly for tests. See add(String) for the format.
  • Constructor Details

    • SimpleEventStreamBuilder

      public SimpleEventStreamBuilder()
  • Method Details

    • add

      public SimpleEventStreamBuilder add(String event)
      Adds one event. The outcome runs up to the first /; the contexts follow it, separated by runs of space, tab, carriage return, line feed and form feed, as in FileEventStream. Other characters remain in the context names. Each context can have a value after a ;:
      other/w=he n1w=belongs n2w=to po=other pow=other,He powf=other,ic
      other/w=he;0.5 n1w=belongs;0.4 n2w=to;0.3 po=other;0.5 pow=other,He;0.25 powf=other,ic;0.5
      
      Parameters:
      event - The event text. Must not be null.
      Returns:
      This builder.
      Throws:
      IllegalArgumentException - Thrown if event is null, if the outcome or the contexts are missing, if the first context has a value and another one is not written as name;value with both parts present and no further ;, or if a value is not a number, is negative, NaN or infinite.
    • build

      public opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event> build()
      Returns a stream over the events added so far. Each call returns a new stream that starts at the first event, and events added later do not appear in it.
      Returns:
      An ObjectStream over the added events, in insertion order. The stream does not support ObjectStream.reset().