You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by rz...@apache.org on 2022/12/28 11:23:25 UTC

[opennlp] branch main updated: OPENNLP-1425 Remove long-time deprecated update method in AbstractDataIndexer

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

rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opennlp.git


The following commit(s) were added to refs/heads/main by this push:
     new 18377036 OPENNLP-1425 Remove long-time deprecated update method in AbstractDataIndexer
18377036 is described below

commit 18377036d9a0505f05220b20928368502fe782c6
Author: Martin Wiesner <ma...@hs-heilbronn.de>
AuthorDate: Tue Dec 27 20:38:51 2022 +0100

    OPENNLP-1425 Remove long-time deprecated update method in AbstractDataIndexer
    
    - removes deprecated `update(String[] ec, Set<String> predicateSet, Map<String,Integer> counter, int cutoff)` method from `AbstractDataIndexer`
    - adds 'Override' annotation where useful and applicable
---
 .../tools/ml/model/AbstractDataIndexer.java        | 30 +++++-----------------
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/opennlp-tools/src/main/java/opennlp/tools/ml/model/AbstractDataIndexer.java b/opennlp-tools/src/main/java/opennlp/tools/ml/model/AbstractDataIndexer.java
index 12137a96..79bdedc5 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/ml/model/AbstractDataIndexer.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/ml/model/AbstractDataIndexer.java
@@ -26,7 +26,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Set;
 
 import opennlp.tools.ml.AbstractTrainer;
 import opennlp.tools.util.InsufficientTrainingDataException;
@@ -83,6 +82,7 @@ public abstract class AbstractDataIndexer implements DataIndexer {
   /**
    * {@inheritDoc}
    */
+  @Override
   public int[][] getContexts() {
     return contexts;
   }
@@ -90,6 +90,7 @@ public abstract class AbstractDataIndexer implements DataIndexer {
   /**
    * {@inheritDoc}
    */
+  @Override
   public int[] getNumTimesEventsSeen() {
     return numTimesEventsSeen;
   }
@@ -97,6 +98,7 @@ public abstract class AbstractDataIndexer implements DataIndexer {
   /**
    * {@inheritDoc}
    */
+  @Override
   public int[] getOutcomeList() {
     return outcomeList;
   }
@@ -104,6 +106,7 @@ public abstract class AbstractDataIndexer implements DataIndexer {
   /**
    * {@inheritDoc}
    */
+  @Override
   public String[] getPredLabels() {
     return predLabels;
   }
@@ -111,6 +114,7 @@ public abstract class AbstractDataIndexer implements DataIndexer {
   /**
    * {@inheritDoc}
    */
+  @Override
   public String[] getOutcomeLabels() {
     return outcomeLabels;
   }
@@ -118,6 +122,7 @@ public abstract class AbstractDataIndexer implements DataIndexer {
   /**
    * {@inheritDoc}
    */
+  @Override
   public int[] getPredCounts() {
     return predCounts;
   }
@@ -125,6 +130,7 @@ public abstract class AbstractDataIndexer implements DataIndexer {
   /**
    * {@inheritDoc}
    */
+  @Override
   public int getNumEvents() {
     return numEvents;
   }
@@ -233,28 +239,6 @@ public abstract class AbstractDataIndexer implements DataIndexer {
     return eventsToCompare;
   }
 
-  /**
-   * Updates the set of predicates and counter with the specified event contexts and cutoff.
-   *
-   * @param ec The contexts/features which occur in a event.
-   * @param predicateSet The set of predicates which will be used for model building.
-   * @param counter The predicate counters.
-   * @param cutoff The cutoff which determines whether a predicate is included.
-   *
-   * @deprecated Use {{@link #update(String[], Map)}}. This method will be removed after 1.8.1 release
-   */
-  @Deprecated
-  protected static void update(String[] ec, Set<String> predicateSet,
-      Map<String,Integer> counter, int cutoff) {
-    for (String s : ec) {
-      counter.merge(s, 1, (value, one) -> value + one);
-
-      if (!predicateSet.contains(s) && counter.get(s) >= cutoff) {
-        predicateSet.add(s);
-      }
-    }
-  }
-
   /**
    * Updates the {@link Map} of predicates and counter with the specified event contexts.
    *