OPENNLP-1894: Harden CJK dictionary loading - #1265
Conversation
Add tests for zero-length categories, multiple character categories, duplicate definitions, invalid word costs, malformed input encoding, and long lexicon entries. Red evidence on current main: eight assertions failed and a 20,000-character surface raised StackOverflowError.
Honor all categories on char.def mappings, use the primary category for unknown-word settings, reject duplicate definitions and invalid word costs, and build lexicon tries without recursive calls.
|
Here are some load bearing comments ;-) I checked the Blocking1. final Map<Category, Integer> runEndByCategory = new IdentityHashMap<>();
2. Taking Counter-example: masks Please confirm against the reference implementation and cite it, or align. The manual text ("all listed categories can extend the character run") describes neither precisely. 3. The manual gains a note on multi-category mappings only. Not documented: empty lexicon surfaces now fail instead of being skipped, duplicate 4. Resolving every recorded Minor
Credit where due: folding Process
|
Red evidence: LatticeTokenizerTest reported three failures for the MeCab category limit and mapping declaration diagnostics.
Red evidence: testCategoryOverlapCanConnectRun returned 2 tokens instead of 1, and testRejectsCharacterCategoryLengthAboveMecabLimit accepted LENGTH 16.
Record the merged apache#1190, apache#1191, apache#1265, and apache#1211 (now supplied by main), the slimmed subword-API-only apache#1165 with its add-ons PR apache#178, the open apache#1266 hunspell follow-up, refreshed PR heads, and the regenerated uber and helper tips.
Summary
char.defmapping while keeping the first category as primary.This is a follow-up to #1191.
Validation
Before the implementation change, the new tests produced eight assertion failures and a
StackOverflowErrorfor a 20,000-character surface../mvnw -q -pl opennlp-core/opennlp-runtime -am -Dopennlp.forkCount=1 -Drat.skip=true test./mvnw -q -pl opennlp-docs -am -Dopennlp.forkCount=1 -Drat.skip=true -DskipTests package