NameFinderEventStream (Apache OpenNLP :: Core :: Runtime 3.0.0-M4 API)
Description: declaration: package: opennlp.tools.namefind, class: NameFinderEventStream

Package opennlp.tools.namefind

# Class NameFinderEventStream

java.lang.Object
opennlp.tools.util.AbstractEventStream<opennlp.tools.namefind.NameSample>
opennlp.tools.namefind.NameFinderEventStream

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

public class NameFinderEventStream extends AbstractEventStream<opennlp.tools.namefind.NameSample>
Class for creating an event stream out of data files for training an `TokenNameFinder`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NameFinderEventStream(opennlp.tools.util.ObjectStream<opennlp.tools.namefind.NameSample> dataStream, String type, opennlp.tools.namefind.NameContextGenerator contextGenerator, opennlp.tools.util.SequenceCodec<String> codec)`
  Initializes a `NameFinderEventStream` using the specified `dataStream` and `NameContextGenerator`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String[][]`
  `additionalContext(String[] tokens, Map<String,String> prevMap)`
  Generated previous decision features for each token based on contents of the specified `prevMap`.
  `static List<opennlp.tools.ml.model.Event>`
  `generateEvents(String[] sentence, String[] outcomes, opennlp.tools.namefind.NameContextGenerator cg)`
  Generates `events` for each token in a `sentence` with the specified `outcomes` using the specified `NameContextGenerator`.
  `static String[]`
  `generateOutcomes(opennlp.tools.util.Span[] names, String type, int length)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  use the `BioCodec` implementation of the SequenceValidator instead!

  ### 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 Details

  - ### NameFinderEventStream

    public NameFinderEventStream(opennlp.tools.util.ObjectStream<opennlp.tools.namefind.NameSample> dataStream, String type, opennlp.tools.namefind.NameContextGenerator contextGenerator, opennlp.tools.util.SequenceCodec<String> codec)
    Initializes a `NameFinderEventStream` using the specified `dataStream` and `NameContextGenerator`.
    Parameters:
      `dataStream` - The `data stream` of events.
      `type` - `null` or overrides the type parameter in the provided samples.
      `contextGenerator` - The `NameContextGenerator` used to generate features for the event stream.
      `codec` - The `SequenceCodec` to use.

- ## Method Details

  - ### generateOutcomes

    @Deprecated(forRemoval=true) public static String[] generateOutcomes(opennlp.tools.util.Span[] names, String type, int length)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use the `BioCodec` implementation of the SequenceValidator instead!
    Generates the name tag outcomes (`start`, `continue`, `other`) for each token in a sentence with the specified `length` using the specified `names`.
    Parameters:
      `names` - Token `spans` for each of the names.
      `type` - `null` or overrides the type parameter in the provided samples
      `length` - The length of the sentence.
    Returns:
      An array of `start`, `continue`, `other` outcomes based on the specified names and sentence `length`.

  - ### generateEvents

    public static List<opennlp.tools.ml.model.Event> generateEvents(String[] sentence, String[] outcomes, opennlp.tools.namefind.NameContextGenerator cg)
    Generates `events` for each token in a `sentence` with the specified `outcomes` using the specified `NameContextGenerator`.
    Parameters:
      `sentence` - Token representing a sentence.
      `outcomes` - An array of outcomes.
      `cg` - The `NameContextGenerator` to use.
    Returns:
      A list of `events` generated.

  - ### additionalContext

    public static String[][] additionalContext(String[] tokens, Map<String,String> prevMap)
    Generated previous decision features for each token based on contents of the specified `prevMap`.
    Parameters:
      `tokens` - The token for which the context is generated.
      `prevMap` - A mapping of tokens to their previous decisions.
    Returns:
      A 2-dimensional array with additional context with features for each token.