ChunkContextGenerator (Apache OpenNLP Tools 2.5.9 API)
Description: declaration: package: opennlp.tools.parser, class: ChunkContextGenerator

# Class ChunkContextGenerator

java.lang.Object
opennlp.tools.parser.ChunkContextGenerator

All Implemented Interfaces:
  `ChunkerContextGenerator, BeamSearchContextGenerator<TokenTag>`

public class ChunkContextGenerator extends Object implements ChunkerContextGenerator
Creates predictive context for the pre-chunking phases of parsing.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ChunkContextGenerator()`
  Initializes a `ChunkContextGenerator` instance.
  `ChunkContextGenerator(int cacheSize)`
  Initializes a `ChunkContextGenerator` instance with a custom `cacheSize`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String[]`
  `getContext(int i, String[] words, String[] tags, String[] preds)`
  Retrieves the contexts for chunking of the specified `idx`.
  `String[]`
  `getContext(int index, TokenTag[] sequence, String[] priorDecisions, Object[] additionalContext)`
  Returns the context for the specified position in the specified `sequence` (list).

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### ChunkContextGenerator

    public ChunkContextGenerator()
    Initializes a `ChunkContextGenerator` instance.

  - ### ChunkContextGenerator

    public ChunkContextGenerator(int cacheSize)
    Initializes a `ChunkContextGenerator` instance with a custom `cacheSize`.
    Parameters:
      `cacheSize` - The cache size. Must be greater than `0` to have an effect.

- ## Method Details

  - ### getContext

    public String[] getContext(int i, String[] words, String[] tags, String[] preds)
    Description copied from interface: `ChunkerContextGenerator`
    Retrieves the contexts for chunking of the specified `idx`.
    Specified by:
      `getContext` in interface `ChunkerContextGenerator`
    Parameters:
      `i` - The index of the token in the specified `toks` array for which the context should be constructed.
      `words` - The tokens of the sentence. The `toString` methods of these objects should return the token text.
      `tags` - The POS tags for the specified tokens.
      `preds` - The previous decisions made in the tagging of this sequence. Only indices less than `idx` will be examined.
    Returns:
      An array of predictive contexts on which a model basis its decisions.

  - ### getContext

    public String[] getContext(int index, TokenTag[] sequence, String[] priorDecisions, Object[] additionalContext)
    Description copied from interface: `BeamSearchContextGenerator`
    Returns the context for the specified position in the specified `sequence` (list).
    Specified by:
      `getContext` in interface `BeamSearchContextGenerator<TokenTag>`
    Parameters:
      `index` - The index of the `sequence`.
      `sequence` - The sequence of `items` over which the beam search is performed.
      `priorDecisions` - The sequence of decisions made prior to the context for which this decision is being made.
      `additionalContext` - Any additional context specific to a class implementing this interface.
    Returns:
      The context for the specified `index` in the specified `sequence`.