opennlp.tools.langdetect

## Class DefaultLanguageDetectorContextGenerator

- java.lang.Object
- - opennlp.tools.langdetect.DefaultLanguageDetectorContextGenerator

- All Implemented Interfaces:
    Serializable, LanguageDetectorContextGenerator

      public class DefaultLanguageDetectorContextGenerator
      extends Object
      implements LanguageDetectorContextGenerator

  A context generator for language detector.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultLanguageDetectorContextGenerator(int minLength, int maxLength, CharSequenceNormalizer... normalizers)` Creates a customizable @`DefaultLanguageDetectorContextGenerator` that computes ngrams from text

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String[]` | `getContext(CharSequence document)` Generates the context for a document using character ngrams.

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

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

- - ### Constructor Detail

    - #### DefaultLanguageDetectorContextGenerator

          public DefaultLanguageDetectorContextGenerator(int minLength,
                                                         int maxLength,
                                                         CharSequenceNormalizer... normalizers)

      Creates a customizable @`DefaultLanguageDetectorContextGenerator` that computes ngrams from text
      Parameters:
        `minLength` - min ngrams chars
        `maxLength` - max ngrams chars
        `normalizers` - zero or more normalizers to be applied in to the text before extracting ngrams

  - ### Method Detail

    - #### getContext

          public String[] getContext(CharSequence document)

      Generates the context for a document using character ngrams.
      Specified by:
        `getContext` in interface `LanguageDetectorContextGenerator`
      Parameters:
        `document` - document to extract context from
      Returns:
        the generated context

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