OPENNLP-1864: Per-language NormalizationProfile registry (2c/7)#1149
Merged
Conversation
The language-to-settings registry split out of the former tokenizer PR (#1104) on review request. NormalizationProfiles maps a language code to its stemmer and diacritic fold (the way OpenNLP already selects a Snowball stemmer by language) and builds a search-oriented TermAnalyzer; NormalizationProfile is the per-language record. Builds on the Term model in 2b.
forLanguage("nb")/("nn") returned empty: the registry keyed Norwegian under the macrolanguage
"nor", but the standard written codes nb/nn convert to ISO 639-3 nob/nno, which were absent from the
map -- so Norwegian text got no profile, and the LanguageDetector (which emits nob/nno) hit the same
hole for a language supportedLanguages() advertises. Added nob/nno aliases to the Norwegian stemmer.
…he enum (profiles) Add a Turkish (tur) normalization profile -- it was the one Snowball language with no profile. Soften the class doc: the covered set is every Snowball algorithm that names a language, i.e. all of them except PORTER (an English-only algorithm variant, not a language). Replace the magic size==21 coverage assertion with one that derives the expected algorithm set from the enum, and add a test for the forLanguage() two-letter fallback when getISO3Language() throws MissingResourceException.
…op 'search' framing in profile docs OpenNLP is not search-specific; rename NormalizationProfile.searchAnalyzer() to matchingAnalyzer() and soften the 'search form/variants' wording in the profile javadocs and the Turkish comment.
Reject null/blank language and a null stemmerAlgorithm in a compact constructor; accentFold stays nullable by design.
…ile in javadoc Addresses mawiesne's review on #1112: - Replace Objects.requireNonNull with fail-loud IllegalArgumentException in the NormalizationProfile compact constructor (language, stemmerAlgorithm) and in NormalizationProfiles.forLanguage/detect, with matching @throws javadoc. - Link the profile term with {@link NormalizationProfile profile} in the forLanguage and detect javadoc. - Flip the null-argument tests to expect IllegalArgumentException and add a detect(null, ...) / detect(..., null) test.
rzo1
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-lands the 2c rung (OPENNLP-1864) onto main. #1112 was approved but merged into its base branch OPENNLP-1850-2b-term instead of main after #1111 landed, so the content never reached main; this is the same reviewed set of commits rebased onto current main.