Skip to content

OPENNLP-1864: Per-language NormalizationProfile registry (2c/7)#1149

Merged
rzo1 merged 6 commits into
mainfrom
OPENNLP-1850-2c-profiles
Jul 6, 2026
Merged

OPENNLP-1864: Per-language NormalizationProfile registry (2c/7)#1149
rzo1 merged 6 commits into
mainfrom
OPENNLP-1850-2c-profiles

Conversation

@krickert

@krickert krickert commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

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.

krickert added 6 commits July 6, 2026 09:05
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 rzo1 merged commit 784e9c8 into main Jul 6, 2026
7 checks passed
@rzo1 rzo1 deleted the OPENNLP-1850-2c-profiles branch July 6, 2026 13:26
@mawiesne mawiesne added java Pull requests that update Java code tests Pull requests that add or update test code labels Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code tests Pull requests that add or update test code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants