This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch feat/GH-1479-tokenizer-character-policy
in repository https://gitbox.apache.org/repos/asf/opennlp.git

commit 559dbac23b41ed2e310467360e6573cac88da37d
Author: Kristian Rickert <[email protected]>
AuthorDate: Fri Oct 23 23:25:31 2026 -0400

    GH-1479: Mark the lang.Factory legacy expression lookups internal and 
deprecated
    
    policyOfLegacyExpression and legacyExpressionOf only serve the deprecated
    Pattern path, so they are marked @Internal and deprecated for removal in 
4.0,
    to go together with the Pattern API. TokenizerFactory suppresses the removal
    warning where it calls them.
    
    Assisted-by: Claude Code 2.1.310
    Co-authored-by: Kristian Rickert <[email protected]>
    Co-authored-by: Claude <[email protected]>
    Reviewed-by: Kristian Rickert <[email protected]>
    Signed-off-by: Kristian Rickert <[email protected]>
---
 .../main/java/opennlp/tools/tokenize/TokenizerFactory.java  |  4 ++++
 .../src/main/java/opennlp/tools/tokenize/lang/Factory.java  | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git 
a/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/TokenizerFactory.java
 
b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/TokenizerFactory.java
index 05dec8c6d..922a60eae 100644
--- 
a/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/TokenizerFactory.java
+++ 
b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/TokenizerFactory.java
@@ -161,6 +161,7 @@ public class TokenizerFactory extends BaseToolFactory {
   }
 
   @Override
+  @SuppressWarnings("removal")
   public Map<String, String> createManifestEntries() {
     Map<String, String> manifestEntries = super.createManifestEntries();
 
@@ -296,6 +297,7 @@ public class TokenizerFactory extends BaseToolFactory {
    */
   @Deprecated(since = "3.0.0", forRemoval = true)
   @SuppressForbidden("user-supplied alphanumeric pattern, kept for the 
deprecated API")
+  @SuppressWarnings("removal")
   public Pattern getAlphaNumericPattern() {
     resolve();
     if (this.alphaNumericPattern != null) {
@@ -390,6 +392,7 @@ public class TokenizerFactory extends BaseToolFactory {
    *         the alphanumeric pattern is not a valid regular expression.
    */
   @SuppressForbidden("user-supplied alphanumeric pattern, kept for the 
deprecated API")
+  @SuppressWarnings("removal")
   private void readManifest() {
     String text = this.artifactProvider.getManifestProperty(CHARACTER_POLICY);
     if (text != null) {
@@ -424,6 +427,7 @@ public class TokenizerFactory extends BaseToolFactory {
    * @param pattern The alphanumeric pattern, or {@code null} for the policy 
of the language.
    */
   @SuppressForbidden("user-supplied alphanumeric pattern, kept for the 
deprecated API")
+  @SuppressWarnings("removal")
   private void setAlphaNumericPattern(Pattern pattern) {
     if (pattern == null) {
       return;
diff --git 
a/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/lang/Factory.java
 
b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/lang/Factory.java
index e2a621451..ede651679 100644
--- 
a/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/lang/Factory.java
+++ 
b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/lang/Factory.java
@@ -21,6 +21,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
+import opennlp.tools.commons.Internal;
 import opennlp.tools.commons.SuppressForbidden;
 import opennlp.tools.tokenize.DefaultTokenContextGenerator;
 import opennlp.tools.tokenize.TokenContextGenerator;
@@ -151,8 +152,14 @@ public class Factory {
    * {@return the policy of the language whose alphanumeric expression of an 
earlier release is
    * {@code expression}, or {@code null} if there is none}
    *
+   * <p>
+   * <b>Note:</b> Internal use only, for the deprecated {@link Pattern} API.
+   *
    * @param expression An alphanumeric expression of an earlier release.
+   * @deprecated Serves only the deprecated {@link Pattern} API and will be 
removed with it in 4.0.
    */
+  @Internal
+  @Deprecated(since = "3.0.0", forRemoval = true)
   public static TokenizerCharacterPolicy policyOfLegacyExpression(String 
expression) {
     for (Map.Entry<TokenizerCharacterPolicy, String> entry : 
LEGACY_EXPRESSIONS.entrySet()) {
       if (entry.getValue().equals(expression)) {
@@ -166,8 +173,14 @@ public class Factory {
    * {@return the alphanumeric expression of an earlier release that accepts 
the same characters
    * as {@code policy}, or {@code null} if there is none}
    *
+   * <p>
+   * <b>Note:</b> Internal use only, for the deprecated {@link Pattern} API.
+   *
    * @param policy A character policy, or {@code null}.
+   * @deprecated Serves only the deprecated {@link Pattern} API and will be 
removed with it in 4.0.
    */
+  @Internal
+  @Deprecated(since = "3.0.0", forRemoval = true)
   public static String legacyExpressionOf(TokenizerCharacterPolicy policy) {
     return policy == null ? null : LEGACY_EXPRESSIONS.get(policy);
   }

Reply via email to