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

# Class ConfigurablePOSContextGenerator

java.lang.Object
opennlp.tools.postag.ConfigurablePOSContextGenerator

All Implemented Interfaces:
  `POSContextGenerator, BeamSearchContextGenerator<String>`

public class ConfigurablePOSContextGenerator extends Object implements POSContextGenerator
A configurable `context generator` for a `POSTagger`. This implementation makes use of `AdaptiveFeatureGenerator`.

See Also:
  - `POSTagger`
  - `POSTaggerME`
  - `DefaultPOSContextGenerator`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConfigurablePOSContextGenerator(int cacheSize, AdaptiveFeatureGenerator featureGenerator)`
  Initializes a `ConfigurablePOSContextGenerator` instance.
  `ConfigurablePOSContextGenerator(AdaptiveFeatureGenerator featureGenerator)`
  Initializes a `ConfigurablePOSContextGenerator` instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String[]`
  `getContext(int index, String[] tokens, String[] tags, Object[] additionalContext)`
  Returns the context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### ConfigurablePOSContextGenerator

    public ConfigurablePOSContextGenerator(AdaptiveFeatureGenerator featureGenerator)
    Initializes a `ConfigurablePOSContextGenerator` instance. A cache size of `0` will be used as default.
    Parameters:
      `featureGenerator` - The `AdaptiveFeatureGenerator` to be used.

  - ### ConfigurablePOSContextGenerator

    public ConfigurablePOSContextGenerator(int cacheSize, AdaptiveFeatureGenerator featureGenerator)
    Initializes a `ConfigurablePOSContextGenerator` instance.
    Parameters:
      `cacheSize` - The size of the `Cache` to set. Must be greater than `0` to have an effect.
      `featureGenerator` - The `AdaptiveFeatureGenerator` to be used.

- ## Method Details

  - ### getContext

    public String[] getContext(int index, String[] tokens, String[] tags, Object[] additionalContext)
    Returns the context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.
    Specified by:
      `getContext` in interface `BeamSearchContextGenerator<String>`
    Specified by:
      `getContext` in interface `POSContextGenerator`
    Parameters:
      `index` - The index of the token for which the context is provided.
      `tokens` - The tokens representing a sentence.
      `tags` - The tags assigned to the previous words in the sentence.
      `additionalContext` - The context for additional information.
    Returns:
      The context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.