You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by ma...@apache.org on 2023/08/27 17:48:42 UTC

[opennlp] branch OPENNLP-1511-Remove-methods-and-constructors-long-time-deprecated-via-JavaDoc created (now ea7123eb)

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

mawiesne pushed a change to branch OPENNLP-1511-Remove-methods-and-constructors-long-time-deprecated-via-JavaDoc
in repository https://gitbox.apache.org/repos/asf/opennlp.git


      at ea7123eb OPENNLP-1511 Remove methods and constructors long-time deprecated via JavaDoc

This branch includes the following new commits:

     new ea7123eb OPENNLP-1511 Remove methods and constructors long-time deprecated via JavaDoc

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[opennlp] 01/01: OPENNLP-1511 Remove methods and constructors long-time deprecated via JavaDoc

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mawiesne pushed a commit to branch OPENNLP-1511-Remove-methods-and-constructors-long-time-deprecated-via-JavaDoc
in repository https://gitbox.apache.org/repos/asf/opennlp.git

commit ea7123eb6e5bcf7b7a091c70a947934fd7079327
Author: Martin Wiesner <ma...@hs-heilbronn.de>
AuthorDate: Sun Aug 27 19:48:36 2023 +0200

    OPENNLP-1511 Remove methods and constructors long-time deprecated via JavaDoc
---
 .../serializer/DictionaryEntryPersistor.java       | 20 -----------
 .../opennlp/tools/languagemodel/LanguageModel.java | 12 -------
 .../tools/languagemodel/NGramLanguageModel.java    | 25 --------------
 .../namefind/DefaultNameContextGenerator.java      | 11 ------
 .../opennlp/tools/namefind/RegexNameFinder.java    | 21 ------------
 .../tools/parser/ChunkContextGenerator.java        | 17 ---------
 .../opennlp/tools/parser/lang/en/HeadRules.java    | 15 --------
 .../opennlp/tools/postag/POSTaggerFactory.java     |  7 ++--
 .../sentdetect/DefaultSDContextGenerator.java      | 16 +--------
 .../tools/sentdetect/SentenceDetectorME.java       | 14 --------
 .../opennlp/tools/sentdetect/SentenceModel.java    | 40 +---------------------
 .../lang/th/SentenceContextGenerator.java          |  3 +-
 .../opennlp/tools/tokenize/SimpleTokenizer.java    |  7 +---
 13 files changed, 9 insertions(+), 199 deletions(-)

diff --git a/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionaryEntryPersistor.java b/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionaryEntryPersistor.java
index 854f99cc..a20891c9 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionaryEntryPersistor.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionaryEntryPersistor.java
@@ -245,26 +245,6 @@ public class DictionaryEntryPersistor {
     return profileContentHandler.mIsCaseSensitiveDictionary;
   }
 
-  /**
-   * Serializes the given entries to the given {@link OutputStream}.
-   * <p>
-   * <b>Note:</b>
-   * After the serialization is finished the provided
-   * {@link OutputStream} remains open.
-   *
-   * @param out The {@link OutputStream} to serialize to.
-   * @param entries The {@link Entry entries} to serialize.
-   *
-   * @throws IOException Thrown if IO errors occurred.
-   * @throws InvalidFormatException Thrown if parameters were invalid.
-   * @deprecated Use {@link DictionaryEntryPersistor#serialize(OutputStream, Iterator, boolean)} instead.
-   */
-  @Deprecated
-  public static void serialize(OutputStream out, Iterator<Entry> entries)
-      throws IOException {
-    DictionaryEntryPersistor.serialize(out, entries, true);
-  }
-
   /**
    * Serializes the given entries to the given {@link OutputStream}.
    * <p>
diff --git a/opennlp-tools/src/main/java/opennlp/tools/languagemodel/LanguageModel.java b/opennlp-tools/src/main/java/opennlp/tools/languagemodel/LanguageModel.java
index 2e8a1909..6453f627 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/languagemodel/LanguageModel.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/languagemodel/LanguageModel.java
@@ -17,8 +17,6 @@
 
 package opennlp.tools.languagemodel;
 
-import opennlp.tools.util.StringList;
-
 /**
  * A language model can calculate the probability <i>p</i> (between 0 and 1) of a
  * certain {@link opennlp.tools.util.StringList sequence of tokens}, given its underlying vocabulary.
@@ -34,16 +32,6 @@ public interface LanguageModel {
    */
   double calculateProbability(String... tokens);
 
-  /**
-   * Predict the most probable output sequence of tokens, given an input sequence of {@code tokens}.
-   *
-   * @param tokens a sequence of tokens.
-   * @return the most probable subsequent token sequence
-   * @deprecated use {@link #predictNextTokens(String...)}
-   */
-  @Deprecated
-  StringList predictNextTokens(StringList tokens);
-
   /**
    * Predict the most probable output sequence of tokens, given an input sequence of {@code tokens}.
    *
diff --git a/opennlp-tools/src/main/java/opennlp/tools/languagemodel/NGramLanguageModel.java b/opennlp-tools/src/main/java/opennlp/tools/languagemodel/NGramLanguageModel.java
index 2b3888ae..02d5e75b 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/languagemodel/NGramLanguageModel.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/languagemodel/NGramLanguageModel.java
@@ -110,31 +110,6 @@ public class NGramLanguageModel extends NGramModel implements LanguageModel {
     return probability;
   }
 
-  @Override
-  @Deprecated
-  public StringList predictNextTokens(StringList tokens) {
-    double maxProb = Double.NEGATIVE_INFINITY;
-    StringList token = null;
-
-    for (StringList ngram : this) {
-      String[] sequence = new String[ngram.size() + tokens.size()];
-      for (int i = 0; i < tokens.size(); i++) {
-        sequence[i] = tokens.getToken(i);
-      }
-      for (int i = 0; i < ngram.size(); i++) {
-        sequence[i + tokens.size()] = ngram.getToken(i);
-      }
-      StringList sample = new StringList(sequence);
-      double v = calculateProbability(sample);
-      if (v > maxProb) {
-        maxProb = v;
-        token = ngram;
-      }
-    }
-
-    return token;
-  }
-
   private double calculateProbability(StringList tokens) {
     double probability = 0d;
     if (size() > 0) {
diff --git a/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java b/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java
index 0f4a2d0b..712d1782 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java
@@ -46,17 +46,6 @@ public class DefaultNameContextGenerator implements NameContextGenerator {
       new PreviousMapFeatureGenerator(),
       new BigramNameFeatureGenerator());
 
-  /**
-   * Creates a name context generator.
-   * 
-   * @deprecated use {@link #DefaultNameContextGenerator(AdaptiveFeatureGenerator...)} and
-   *             always provide one or more {@link AdaptiveFeatureGenerator feature generators}.
-   */
-  @Deprecated
-  public DefaultNameContextGenerator() {
-    this((AdaptiveFeatureGenerator[]) null);
-  }
-
   /**
    * Creates a name context generator with the specified
    * {@link AdaptiveFeatureGenerator feature generators}.
diff --git a/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java b/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java
index 13007aa5..b8239c28 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/namefind/RegexNameFinder.java
@@ -64,27 +64,6 @@ public final class RegexNameFinder implements TokenNameFinder {
     sType = type;
   }
 
-
-  /**
-   * Initializes a {@link RegexNameFinder} instance.
-   *
-   * @param patterns The {@link Pattern[] patterns} to use.
-   *                 Must not be {@code null} and not be empty.
-   *
-   * @throws IllegalArgumentException Thrown if {@code patterns} were {@code null} or empty.
-   * @deprecated Use constructor {@link #RegexNameFinder(Pattern[], String)}
-   *             for single types, and/or constructor {@link #RegexNameFinder(Map)} instead.
-   */
-  @Deprecated
-  public RegexNameFinder(Pattern[] patterns) {
-    if (patterns == null || patterns.length == 0) {
-      throw new IllegalArgumentException("patterns must not be null or empty!");
-    }
-
-    mPatterns = patterns;
-    sType = null;
-  }
-
   @Override
   public Span[] find(String[] tokens) {
     Map<Integer, Integer> sentencePosTokenMap = new HashMap<>();
diff --git a/opennlp-tools/src/main/java/opennlp/tools/parser/ChunkContextGenerator.java b/opennlp-tools/src/main/java/opennlp/tools/parser/ChunkContextGenerator.java
index 0b1b8505..9766e95a 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/parser/ChunkContextGenerator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/parser/ChunkContextGenerator.java
@@ -52,23 +52,6 @@ public class ChunkContextGenerator implements ChunkerContextGenerator {
     }
   }
 
-  /**
-   * @deprecated Use {@link #getContext(int, String[], String[], String[])} instead.
-   */
-  @Deprecated
-  public String[] getContext(Object o) {
-    Object[] data = (Object[]) o;
-    return getContext((Integer) data[0], (String[]) data[1], (String[]) data[2], (String[]) data[3]);
-  }
-
-  /**
-   * @deprecated Use {@link #getContext(int, String[], String[], String[])} instead.
-   */
-  @Deprecated
-  public String[] getContext(int i, String[] words, String[] prevDecisions, Object[] ac) {
-    return getContext(i,words,(String[]) ac[0],prevDecisions);
-  }
-
   @Override
   public String[] getContext(int i, String[] words, String[] tags, String[] preds) {
     List<String> features = new ArrayList<>(19);
diff --git a/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java b/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java
index eb3c2c91..dd4e8b89 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/parser/lang/en/HeadRules.java
@@ -18,7 +18,6 @@
 package opennlp.tools.parser.lang.en;
 
 import java.io.BufferedReader;
-import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -99,20 +98,6 @@ public class HeadRules implements opennlp.tools.parser.HeadRules, GapLabeler, Se
   private Map<String, HeadRule> headRules;
   private final Set<String> punctSet;
 
-  /**
-   * Creates a new set of head rules based on the specified {@code ruleFile}.
-   *
-   * @param ruleFile A string representation for a head rules file.
-   *
-   * @throws IOException Thrown if the head rules file can not be read.
-   *
-   * @deprecated Use {@link #HeadRules(Reader)} instead.
-   */
-  @Deprecated
-  public HeadRules(String ruleFile) throws IOException {
-    this(new FileReader(ruleFile));
-  }
-
   /**
    * Creates a new set of head rules based on the specified reader.
    *
diff --git a/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerFactory.java b/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerFactory.java
index c9be3053..94b0aa63 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerFactory.java
@@ -83,9 +83,8 @@ public class POSTaggerFactory extends BaseToolFactory {
     this.posDictionary = posDictionary;
   }
 
-
   // reduced visibility to ensure deprecation is respected in future versions
-  @Deprecated
+  @Deprecated(forRemoval = true)
   POSTaggerFactory(Dictionary ngramDictionary, TagDictionary posDictionary) {
     this.init(ngramDictionary, posDictionary);
 
@@ -94,8 +93,8 @@ public class POSTaggerFactory extends BaseToolFactory {
   }
 
   // reduced visibility to ensure deprecation is respected in future versions
-  @Deprecated
   // will be removed when only 8 series models are supported
+  @Deprecated(forRemoval = true)
   void init(Dictionary ngramDictionary, TagDictionary posDictionary) {
     this.ngramDictionary = ngramDictionary;
     this.posDictionary = posDictionary;
@@ -316,10 +315,12 @@ public class POSTaggerFactory extends BaseToolFactory {
   // use the SerializableArtifact interface
   public static class POSDictionarySerializer implements ArtifactSerializer<POSDictionary> {
 
+    @Override
     public POSDictionary create(InputStream in) throws IOException {
       return POSDictionary.create(new UncloseableInputStream(in));
     }
 
+    @Override
     public void serialize(POSDictionary artifact, OutputStream out)
         throws IOException {
       artifact.serialize(out);
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
index f972d575..e28d3c9f 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
@@ -159,21 +159,7 @@ public class DefaultSDContextGenerator implements SDContextGenerator {
     collectFeats.clear();
     return context;
   }
-
-  /**
-   * Determines some features for the sentence detector and adds them to list features.
-   *
-   * @param prefix String preceding the eos character in the eos token.
-   * @param suffix String following the eos character in the eos token.
-   * @param previous Space delimited token preceding token containing eos character.
-   * @param next Space delimited token following token containing eos character.
-   *
-   * @deprecated use {@link #collectFeatures(String, String, String, String, Character)} instead.
-   */
-  protected void collectFeatures(String prefix, String suffix, String previous, String next) {
-    collectFeatures(prefix, suffix, previous, next, null);
-  }
-
+  
   /**
    * Determines some features for the sentence detector and adds them to list features.
    *
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
index 93d523c7..970ecd2e 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 package opennlp.tools.sentdetect;
 
 import java.io.IOException;
@@ -309,19 +308,6 @@ public class SentenceDetectorME implements SentenceDetector {
     return true;
   }
 
-  /**
-   * @deprecated Use
-   *             {@link #train(String, ObjectStream, SentenceDetectorFactory, TrainingParameters)}
-   *             and pass in af {@link SentenceDetectorFactory}.
-   */
-  public static SentenceModel train(String languageCode,
-      ObjectStream<SentenceSample> samples, boolean useTokenEnd,
-      Dictionary abbreviations, TrainingParameters mlParams) throws IOException {
-    SentenceDetectorFactory sdFactory = new SentenceDetectorFactory(
-        languageCode, useTokenEnd, abbreviations, null);
-    return train(languageCode, samples, sdFactory, mlParams);
-  }
-
   public static SentenceModel train(String languageCode,
       ObjectStream<SentenceSample> samples, SentenceDetectorFactory sdFactory,
       TrainingParameters mlParams) throws IOException {
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceModel.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceModel.java
index 8caff463..0f164a9f 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceModel.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceModel.java
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 package opennlp.tools.sentdetect;
 
 import java.io.File;
@@ -40,7 +39,7 @@ import opennlp.tools.util.model.ModelUtil;
  */
 public class SentenceModel extends BaseModel {
 
-  private static final long serialVersionUID = -3921848998444722554L;
+  private static final long serialVersionUID = -8374532795287293730L;
   private static final String COMPONENT_NAME = "SentenceDetectorME";
   private static final String MAXENT_MODEL_ENTRY_NAME = "sent.model";
 
@@ -51,43 +50,6 @@ public class SentenceModel extends BaseModel {
     checkArtifactMap();
   }
 
-  /**
-   * TODO: was added in 1.5.3 -&gt; remove
-   * @deprecated Use
-   *             {@link #SentenceModel(String, MaxentModel, Map, SentenceDetectorFactory)}
-   *             instead and pass in a {@link SentenceDetectorFactory}
-   */
-  public SentenceModel(String languageCode, MaxentModel sentModel, boolean useTokenEnd,
-      Dictionary abbreviations, char[] eosCharacters, Map<String, String> manifestInfoEntries) {
-    this(languageCode, sentModel, manifestInfoEntries,
-        new SentenceDetectorFactory(languageCode, useTokenEnd, abbreviations,
-            eosCharacters));
-  }
-
-  /**
-   * TODO: was added in 1.5.3 -&gt; remove
-   *
-   * @deprecated Use
-   *             {@link #SentenceModel(String, MaxentModel, Map, SentenceDetectorFactory)}
-   *             instead and pass in a {@link SentenceDetectorFactory}
-   */
-  public SentenceModel(String languageCode, MaxentModel sentModel,
-      boolean useTokenEnd, Dictionary abbreviations, char[] eosCharacters) {
-    this(languageCode, sentModel, useTokenEnd, abbreviations, eosCharacters,
-        null);
-  }
-
-  public SentenceModel(String languageCode, MaxentModel sentModel,
-      boolean useTokenEnd, Dictionary abbreviations, Map<String, String> manifestInfoEntries) {
-    this(languageCode, sentModel, useTokenEnd, abbreviations, null,
-        manifestInfoEntries);
-  }
-
-  public SentenceModel(String languageCode, MaxentModel sentModel,
-      boolean useTokenEnd, Dictionary abbreviations) {
-    this (languageCode, sentModel, useTokenEnd, abbreviations, null, null);
-  }
-
   public SentenceModel(InputStream in) throws IOException {
     super(COMPONENT_NAME, in);
   }
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/lang/th/SentenceContextGenerator.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/lang/th/SentenceContextGenerator.java
index f87d6ca3..002b4f4d 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/lang/th/SentenceContextGenerator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/lang/th/SentenceContextGenerator.java
@@ -31,7 +31,8 @@ public class SentenceContextGenerator extends DefaultSDContextGenerator {
   }
 
   @Override
-  protected void collectFeatures(String prefix, String suffix, String previous, String next) {
+  protected void collectFeatures(String prefix, String suffix, String previous, String next,
+                                 Character eosChar) {
     buf.append("p=");
     buf.append(prefix);
     collectFeats.add(buf.toString());
diff --git a/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java b/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java
index a2f5c14f..d545f95c 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/tokenize/SimpleTokenizer.java
@@ -56,12 +56,7 @@ public class SimpleTokenizer extends AbstractTokenizer {
    */
   public static final SimpleTokenizer INSTANCE = new SimpleTokenizer();
 
-  /**
-   * @deprecated Use {@link SimpleTokenizer#INSTANCE} field instead to obtain an instance.
-   *     This constructor will be made private in the future.
-   */
-  @Deprecated // TODO Decide when this will be private (see deprecation note!)
-  public SimpleTokenizer() {
+  private SimpleTokenizer() {
   }
 
   @Override