You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/09/24 14:22:19 UTC

[commons-text] branch master updated (aec0a326 -> fe8b612a)

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

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git


    from aec0a326 Bump junit-jupiter from 5.9.0 to 5.9.1
     new 8cf28a58 Javadoc
     new fe8b612a Fix PMD CPD error by delegating deprecated method to new method

The 2 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.


Summary of changes:
 .../text/similarity/JaroWinklerDistance.java       | 57 +---------------------
 1 file changed, 2 insertions(+), 55 deletions(-)


[commons-text] 01/02: Javadoc

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 8cf28a58b09cd8197093c7a3517fda3fae8258d9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 24 10:18:42 2022 -0400

    Javadoc
---
 .../java/org/apache/commons/text/similarity/JaroWinklerDistance.java   | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
index 892f456b..932a63f7 100644
--- a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
@@ -32,7 +32,6 @@ public class JaroWinklerDistance implements EditDistance<Double> {
     @Deprecated
     public static final int INDEX_NOT_FOUND = -1;
 
-    // TODO: remove this method in 2.0, see TEXT-104
     /**
      * This method returns the Jaro-Winkler string matches, half transpositions, prefix array.
      *
@@ -40,7 +39,7 @@ public class JaroWinklerDistance implements EditDistance<Double> {
      * @param second the second string to be matched
      * @return mtp array containing: matches, half transpositions, and prefix
      * @deprecated Deprecated as of 1.7. This method will be removed in 2.0, and moved to a Jaro Winkler similarity
-     *             class.
+     *             class. TODO see TEXT-104.
      */
     @Deprecated
     protected static int[] matches(final CharSequence first, final CharSequence second) {


[commons-text] 02/02: Fix PMD CPD error by delegating deprecated method to new method

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit fe8b612a7c25d23707fb91e3cacc0bf467bc1a26
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 24 10:22:15 2022 -0400

    Fix PMD CPD error by delegating deprecated method to new method
---
 .../text/similarity/JaroWinklerDistance.java       | 54 +---------------------
 1 file changed, 1 insertion(+), 53 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
index 932a63f7..85d0b3f7 100644
--- a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
@@ -43,59 +43,7 @@ public class JaroWinklerDistance implements EditDistance<Double> {
      */
     @Deprecated
     protected static int[] matches(final CharSequence first, final CharSequence second) {
-        final CharSequence max;
-        final CharSequence min;
-        if (first.length() > second.length()) {
-            max = first;
-            min = second;
-        } else {
-            max = second;
-            min = first;
-        }
-        final int range = Math.max(max.length() / 2 - 1, 0);
-        final int[] matchIndexes = new int[min.length()];
-        Arrays.fill(matchIndexes, -1);
-        final boolean[] matchFlags = new boolean[max.length()];
-        int matches = 0;
-        for (int mi = 0; mi < min.length(); mi++) {
-            final char c1 = min.charAt(mi);
-            for (int xi = Math.max(mi - range, 0), xn = Math.min(mi + range + 1, max.length()); xi < xn; xi++) {
-                if (!matchFlags[xi] && c1 == max.charAt(xi)) {
-                    matchIndexes[mi] = xi;
-                    matchFlags[xi] = true;
-                    matches++;
-                    break;
-                }
-            }
-        }
-        final char[] ms1 = new char[matches];
-        final char[] ms2 = new char[matches];
-        for (int i = 0, si = 0; i < min.length(); i++) {
-            if (matchIndexes[i] != -1) {
-                ms1[si] = min.charAt(i);
-                si++;
-            }
-        }
-        for (int i = 0, si = 0; i < max.length(); i++) {
-            if (matchFlags[i]) {
-                ms2[si] = max.charAt(i);
-                si++;
-            }
-        }
-        int halfTranspositions = 0;
-        for (int mi = 0; mi < ms1.length; mi++) {
-            if (ms1[mi] != ms2[mi]) {
-                halfTranspositions++;
-            }
-        }
-        int prefix = 0;
-        for (int mi = 0; mi < Math.min(4, min.length()); mi++) {
-            if (first.charAt(mi) != second.charAt(mi)) {
-                break;
-            }
-            prefix++;
-        }
-        return new int[] {matches, halfTranspositions, prefix};
+        return JaroWinklerSimilarity.matches(first, second);
     }
 
     /**