POSSampleEventStream (Apache OpenNLP Tools 1.9.5 API)
Date: 2026-06-18

opennlp.tools.postag

## Class POSSampleEventStream

- java.lang.Object
- - opennlp.tools.util.AbstractEventStream<POSSample>
  - - opennlp.tools.postag.POSSampleEventStream

- All Implemented Interfaces:
    AutoCloseable, ObjectStream<Event>

      public class POSSampleEventStream
      extends AbstractEventStream<POSSample>

  This class reads the `POSSample`s from the given `Iterator` and converts the `POSSample`s into `Event`s which can be used by the maxent library for training.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `POSSampleEventStream(ObjectStream<POSSample> samples)` Initializes the current instance with given samples and a `DefaultPOSContextGenerator`.
    `POSSampleEventStream(ObjectStream<POSSample> samples, POSContextGenerator cg)` Initializes the current instance with the given samples and the given `POSContextGenerator`.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static List<Event>` | `generateEvents(String[] sentence, String[] tags, Object[] additionalContext, POSContextGenerator cg)`
    `static List<Event>` | `generateEvents(String[] sentence, String[] tags, POSContextGenerator cg)`

    - ### Methods inherited from class opennlp.tools.util.AbstractEventStream

      `close, read, reset`

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

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

- - ### Constructor Detail

    - #### POSSampleEventStream

          public POSSampleEventStream(ObjectStream<POSSample> samples,
                                      POSContextGenerator cg)

      Initializes the current instance with the given samples and the given `POSContextGenerator`.
      Parameters:
        `samples` -
        `cg` -

    - #### POSSampleEventStream

          public POSSampleEventStream(ObjectStream<POSSample> samples)

      Initializes the current instance with given samples and a `DefaultPOSContextGenerator`.
      Parameters:
        `samples` -

  - ### Method Detail

    - #### generateEvents

          public static List<Event> generateEvents(String[] sentence,
                                                   String[] tags,
                                                   Object[] additionalContext,
                                                   POSContextGenerator cg)

    - #### generateEvents

          public static List<Event> generateEvents(String[] sentence,
                                                   String[] tags,
                                                   POSContextGenerator cg)

Copyright © 2026 The Apache Software Foundation. All rights reserved.