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

opennlp.tools.postag

## Class ConfigurablePOSContextGenerator

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

- All Implemented Interfaces:
    POSContextGenerator, BeamSearchContextGenerator<String>

      public class ConfigurablePOSContextGenerator
      extends Object
      implements POSContextGenerator

  A context generator for the POS Tagger.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConfigurablePOSContextGenerator(AdaptiveFeatureGenerator featureGenerator)` Initializes the current instance.
    `ConfigurablePOSContextGenerator(int cacheSize, AdaptiveFeatureGenerator featureGenerator)` Initializes the current instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String[]` | `getContext(int index, String[] tokens, String[] tags, Object[] additionalContext)` Returns the context for making a pos tag decision at the specified token index given the specified tokens and previous tags.

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

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

- - ### Constructor Detail

    - #### ConfigurablePOSContextGenerator

          public ConfigurablePOSContextGenerator(int cacheSize,
                                                 AdaptiveFeatureGenerator featureGenerator)

      Initializes the current instance.
      Parameters:
        `cacheSize` -

    - #### ConfigurablePOSContextGenerator

          public ConfigurablePOSContextGenerator(AdaptiveFeatureGenerator featureGenerator)

      Initializes the current instance.

  - ### Method Detail

    - #### getContext

          public String[] getContext(int index,
                                     String[] tokens,
                                     String[] tags,
                                     Object[] additionalContext)

      Returns the context for making a pos tag decision at the specified token index given the specified tokens and previous tags.
      Specified by:
        `getContext` in interface `POSContextGenerator`
      Specified by:
        `getContext` in interface `BeamSearchContextGenerator<String>`
      Parameters:
        `index` - The index of the token for which the context is provided.
        `tokens` - The tokens in the sentence.
        `tags` - The tags assigned to the previous words in the sentence.
        `additionalContext` - Any addition context specific to a class implementing this interface.
      Returns:
        The context for making a pos tag decision at the specified token index given the specified tokens and previous tags.

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