Package opennlp.tools.util.normalizer
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 benullor blank.stemmerAlgorithm- The Snowball algorithm for the language. Must not benull.accentFold- The diacritic fold for the language, ornullfor 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 Summary
ConstructorsConstructorDescriptionNormalizationProfile(String language, SnowballStemmer.ALGORITHM stemmerAlgorithm, opennlp.tools.util.normalizer.CharSequenceNormalizer accentFold) Validates the components. -
Method Summary
Modifier and TypeMethodDescriptionopennlp.tools.util.normalizer.CharSequenceNormalizerReturns the value of theaccentFoldrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.language()Returns the value of thelanguagerecord component.Returns a matching analyzer for this language: NFC, case folding, the language's diacritic fold when it has one, then stemming.opennlp.tools.stemmer.StemmerReturns a newStemmerfor this language.Returns the value of thestemmerAlgorithmrecord component.opennlp.tools.stemmer.StemmerFactoryReturns a thread-safe factory for this language's Snowball stemmer.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
NormalizationProfile
public NormalizationProfile(String language, SnowballStemmer.ALGORITHM stemmerAlgorithm, opennlp.tools.util.normalizer.CharSequenceNormalizer accentFold) Validates the components.- Throws:
IllegalArgumentException- iflanguageorstemmerAlgorithmisnull, or iflanguageis 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 newStemmerfor this language. The returnedSnowballStemmeris thread-safe and may be shared across threads.- Returns:
- a new
Stemmerfor this language
-
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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
language
Returns the value of thelanguagerecord component.- Returns:
- the value of the
languagerecord component
-
stemmerAlgorithm
Returns the value of thestemmerAlgorithmrecord component.- Returns:
- the value of the
stemmerAlgorithmrecord component
-
accentFold
public opennlp.tools.util.normalizer.CharSequenceNormalizer accentFold()Returns the value of theaccentFoldrecord component.- Returns:
- the value of the
accentFoldrecord component
-