Record Class NormalizationProfile

java.lang.Object
java.lang.Record
opennlp.tools.util.normalizer.NormalizationProfile
Record Components:
language - The language, as an ISO 639-3 code (for example "eng"). Must not be null or blank.
stemmerAlgorithm - The Snowball algorithm for the language. Must not be null.
accentFold - The diacritic fold for the language, or null for none.

public record NormalizationProfile(String language, SnowballStemmer.ALGORITHM stemmerAlgorithm, opennlp.tools.util.normalizer.CharSequenceNormalizer accentFold) extends Record
Per-language normalization settings, mirroring how OpenNLP already selects a Snowball stemmer by language. A profile pairs a language with its Snowball SnowballStemmer.ALGORITHM and the diacritic fold appropriate for that language (if any).

The accentFold normalizer is the language's diacritic transform for a matching form, or null when folding is not appropriate. It is the generic AccentFoldCharSequenceNormalizer for English and the major Romance languages (where accented letters are matching variants of their base letter), the German-specific GermanUmlautCharSequenceNormalizer (a-umlaut to ae, eszett to ss, ...) for German, and null where diacritics mark distinct letters (the Nordic languages and the non-Latin scripts), because folding there is language-wrong. This is a search-recall choice, not a statement of linguistic correctness; callers can build a TermAnalyzer directly to override it.

  • Constructor Details

    • NormalizationProfile

      public NormalizationProfile(String language, SnowballStemmer.ALGORITHM stemmerAlgorithm, opennlp.tools.util.normalizer.CharSequenceNormalizer accentFold)
      Validates the components.
      Throws:
      IllegalArgumentException - if language or stemmerAlgorithm is null, or if language is blank.
  • Method Details

    • stemmerFactory

      public opennlp.tools.stemmer.StemmerFactory stemmerFactory()
      Returns a thread-safe factory for this language's Snowball stemmer. The factory may be shared; each minted stemmer is confined to the calling thread.
      Returns:
      a thread-safe factory for this language's Snowball stemmer
    • newStemmer

      public opennlp.tools.stemmer.Stemmer newStemmer()
      Returns a new Stemmer for this language. The returned SnowballStemmer is thread-safe and may be shared across threads.
      Returns:
      a new Stemmer for this language
    • matchingAnalyzer

      public TermAnalyzer matchingAnalyzer()
      Returns a matching analyzer for this language: NFC, case folding, the language's diacritic fold when it has one, then stemming. The returned analyzer is thread-safe, and repeated words resolve from a bounded per-thread stem cache instead of being re-stemmed. The cache is keyed to the thread, so build the analyzer once and reuse it from threads that live across many calls, such as a fixed platform-thread pool.
      Returns:
      the analyzer.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • language

      public String language()
      Returns the value of the language record component.
      Returns:
      the value of the language record component
    • stemmerAlgorithm

      public SnowballStemmer.ALGORITHM stemmerAlgorithm()
      Returns the value of the stemmerAlgorithm record component.
      Returns:
      the value of the stemmerAlgorithm record component
    • accentFold

      public opennlp.tools.util.normalizer.CharSequenceNormalizer accentFold()
      Returns the value of the accentFold record component.
      Returns:
      the value of the accentFold record component