Repository navigation
OPENNLP-1973: Regex removal (prep): Add a CompatibilityMode switch for the earlier output - #1312
Merged
Merged
Conversation
CompatibilityMode holds LEGACY or CURRENT, resolved from the system property opennlp.compat.mode and overridable with setActive and reset. Classes whose output was corrected consult it so models trained with an earlier release keep their input. Built like the whitespace mode switch and scheduled for removal in 4.0.
This was referenced Sep 18, 2026
Contributor
|
Thank you for doing this! |
krickert
approved these changes
Sep 18, 2026
krickert
left a comment
Contributor
There was a problem hiding this comment.
Looks good as-is.
Notes from AI but it's very nit:
- Invalid property values fail at class initialization. fromProperty() runs in the static initializer, so -Dopennlp.compat.mode=bogus surfaces as an ExceptionInInitializerError on first use and NoClassDefFoundError after. WhitespaceMode behaves the same, so this is consistent, and the test deliberately initializes with a clean property. A sentence in the Javadoc of MODE_PROPERTY saying the failure happens at startup would make that visible.
- The two mode enums duplicate fromProperty and warnIfLegacy. A tiny package-private helper would remove it, but that is a preference and touches a class already on main.
Contributor
Author
|
Thanks! Added the sentence on class initialization to the |
This was referenced Sep 18, 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.
Prerequisite for the regex removal (OPENNLP-1926). Split out of #1275.
Adds
opennlp.tools.util.CompatibilityModeto opennlp-api withLEGACYandCURRENT, resolved from-Dopennlp.compat.modeat startup and overridable withsetActiveandreset.CURRENTis the default;LEGACYlogs one warning per process. Built like the whitespace mode switch and scheduled for removal in 4.0 with it.Classes whose output was corrected consult it so that models trained with an earlier release still get the input they were trained on. Users: the EmojiCharSequenceNormalizer fix (#1313, part 8, OPENNLP-1974, stacked on this PR) and the surrogate rule of #1281 (OPENNLP-1934).
Commits by @krickert from #1275, regrouped.