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

opennlp.tools.tokenize

## Class DefaultTokenContextGenerator

- java.lang.Object
- - opennlp.tools.tokenize.DefaultTokenContextGenerator

- All Implemented Interfaces:
    TokenContextGenerator

      public class DefaultTokenContextGenerator
      extends Object
      implements TokenContextGenerator

  Generate events for maxent decisions for tokenization.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultTokenContextGenerator()` Creates a default context generator for tokenizer.
    `DefaultTokenContextGenerator(Set<String> inducedAbbreviations)` Creates a default context generator for tokenizer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String[]` | `getContext(String sentence, int index)` Returns an array of features for the specified sentence string at the specified index.

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

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

- - ### Constructor Detail

    - #### DefaultTokenContextGenerator

          public DefaultTokenContextGenerator()

      Creates a default context generator for tokenizer.

    - #### DefaultTokenContextGenerator

          public DefaultTokenContextGenerator(Set<String> inducedAbbreviations)

      Creates a default context generator for tokenizer.
      Parameters:
        `inducedAbbreviations` - the induced abbreviations

  - ### Method Detail

    - #### getContext

          public String[] getContext(String sentence,
                                     int index)

      Description copied from interface: `TokenContextGenerator`
      Returns an array of features for the specified sentence string at the specified index.
      Specified by:
        `getContext` in interface `TokenContextGenerator`
      Parameters:
        `sentence` - The string for a sentence.
        `index` - The index to consider splitting as a token.
      Returns:
        an array of features for the specified sentence string at the specified index.

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