commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [23/50] [lang] Revert "LANG-1269: Wrong name or result of StringUtils#getJaroWinklerDistance (closes #198)"
Date Mon, 17 Apr 2017 12:19:46 GMT
Revert "LANG-1269: Wrong name or result of StringUtils#getJaroWinklerDistance (closes #198)"

This reverts commit a40b2a907a69e51675d7d0502b2608833c4da343, because adding a new method
StringUtils#getJaroWinklerSimilarity and immediately deprecating it makes not sense.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/f4ee399e
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/f4ee399e
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/f4ee399e

Branch: refs/heads/release
Commit: f4ee399e31eb61741f5f2167d6af8f49c0e991b6
Parents: 844cd42
Author: pascalschumacher <pascalschumacher@gmx.net>
Authored: Sun Mar 19 14:25:20 2017 +0100
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Sun Mar 19 14:25:20 2017 +0100

----------------------------------------------------------------------
 src/changes/changes.xml                         |  1 -
 .../org/apache/commons/lang3/StringUtils.java   | 54 --------------------
 .../apache/commons/lang3/StringUtilsTest.java   | 28 ----------
 3 files changed, 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/f4ee399e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ee3097d..3edd5e6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,7 +54,6 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1287" type="fix" dev="pschumacher" due-to="Ivan Morozov">RandomStringUtils#random
can enter infinite loop if end parameter is to small</action>
     <action issue="LANG-1285" type="fix" dev="pschumacher" due-to="Francesco Chicchiriccò">NullPointerException
in FastDateParser$TimeZoneStrategy</action>
     <action issue="LANG-1281" type="fix" dev="pschumacher" due-to="Andreas Lundblad">Javadoc
of StringUtils.ordinalIndexOf is contradictory.</action>
-    <action issue="LANG-1269" type="fix" dev="pschumacher">Wrong name or result of
StringUtils#getJaroWinklerDistance</action>
     <action issue="LANG-1188" type="fix" dev="pschumacher">StringUtils#join(T...):
warning: [unchecked] Possible heap pollution from parameterized vararg type T</action>
     <action issue="LANG-1144" type="fix" dev="ggregory" due-to="Waldemar Maier, Gary Gregory">Multiple
calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible.</action>
     <action issue="LANG-1276" type="fix" dev="pschumacher" due-to="Andy Klimczak">StrBuilder#replaceAll
ArrayIndexOutOfBoundsException</action>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/f4ee399e/src/main/java/org/apache/commons/lang3/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 6e32a5c..26aea76 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -8213,7 +8213,6 @@ public class StringUtils {
      * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/similarity/JaroWinklerDistance.html">
      * JaroWinklerDistance</a> instead
      */
-    @Deprecated
     public static double getJaroWinklerDistance(final CharSequence first, final CharSequence
second) {
         final double DEFAULT_SCALING_FACTOR = 0.1;
 
@@ -8231,59 +8230,6 @@ public class StringUtils {
         return Math.round(jw * 100.0D) / 100.0D;
     }
 
-    /**
-     * <p>Find the Jaro Winkler Similarity which indicates the similarity score between
two Strings.</p>
-     *
-     * <p>The Jaro measure is the weighted sum of percentage of matched characters
from each file and transposed characters. 
-     * Winkler increased this measure for matching initial characters.</p>
-     *
-     * <p>This implementation is based on the Jaro Winkler similarity algorithm
-     * from <a href="http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance">http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance</a>.</p>
-     * 
-     * <pre>
-     * StringUtils.getJaroWinklerSimilarity(null, null)          = IllegalArgumentException
-     * StringUtils.getJaroWinklerSimilarity("","")               = 0.0
-     * StringUtils.getJaroWinklerSimilarity("","a")              = 0.0
-     * StringUtils.getJaroWinklerSimilarity("aaapppp", "")       = 0.0
-     * StringUtils.getJaroWinklerSimilarity("frog", "fog")       = 0.93
-     * StringUtils.getJaroWinklerSimilarity("fly", "ant")        = 0.0
-     * StringUtils.getJaroWinklerSimilarity("elephant", "hippo") = 0.44
-     * StringUtils.getJaroWinklerSimilarity("hippo", "elephant") = 0.44
-     * StringUtils.getJaroWinklerSimilarity("hippo", "zzzzzzzz") = 0.0
-     * StringUtils.getJaroWinklerSimilarity("hello", "hallo")    = 0.88
-     * StringUtils.getJaroWinklerSimilarity("ABC Corporation", "ABC Corp") = 0.93
-     * StringUtils.getJaroWinklerSimilarity("D N H Enterprises Inc", "D &amp; H Enterprises,
Inc.") = 0.95
-     * StringUtils.getJaroWinklerSimilarity("My Gym Children's Fitness Center", "My Gym.
Childrens Fitness") = 0.92
-     * StringUtils.getJaroWinklerSimilarity("PENNSYLVANIA", "PENNCISYLVNIA") = 0.88
-     * </pre>
-     *
-     * @param first the first String, must not be null
-     * @param second the second String, must not be null
-     * @return result similarity
-     * @throws IllegalArgumentException if either String input {@code null}
-     * @since 3.6
-     * @deprecated as of 3.6, use commons-text
-     * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/similarity/JaroWinklerDistance.html">
-     * JaroWinklerDistance</a> instead
-     */
-    @Deprecated
-    public static double getJaroWinklerSimilarity(final CharSequence first, final CharSequence
second) {
-        final double DEFAULT_SCALING_FACTOR = 0.1;
-
-        if (first == null || second == null) {
-            throw new IllegalArgumentException("Strings must not be null");
-        }
-
-        final int[] mtp = matches(first, second);
-        final double m = mtp[0];
-        if (m == 0) {
-            return 0D;
-        }
-        final double j = ((m / first.length() + m / second.length() + (m - mtp[1]) / m))
/ 3;
-        final double jw = j < 0.7D ? j : j + Math.min(DEFAULT_SCALING_FACTOR, 1D / mtp[3])
* mtp[2] * (1D - j);
-        return Math.round(jw * 100.0D) / 100.0D;
-    }
-
     private static int[] matches(final CharSequence first, final CharSequence second) {
         CharSequence max, min;
         if (first.length() > second.length()) {

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/f4ee399e/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index 8c76144..b776b3b 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -2507,34 +2507,6 @@ public class StringUtilsTest {
     }
 
     @Test
-    public void testGetJaroWinklerSimilarity_StringString() {
-        assertEquals(0.93d, StringUtils.getJaroWinklerSimilarity("frog", "fog"), 0.0d);
-        assertEquals(0.0d, StringUtils.getJaroWinklerSimilarity("fly", "ant"), 0.0d);
-        assertEquals(0.44d, StringUtils.getJaroWinklerSimilarity("elephant", "hippo"), 0.0d);
-        assertEquals(0.84d, StringUtils.getJaroWinklerSimilarity("dwayne", "duane"), 0.0d);
-        assertEquals(0.93d, StringUtils.getJaroWinklerSimilarity("ABC Corporation", "ABC
Corp"), 0.0d);
-        assertEquals(0.95d, StringUtils.getJaroWinklerSimilarity("D N H Enterprises Inc",
"D & H Enterprises, Inc."), 0.0d);
-        assertEquals(0.92d, StringUtils.getJaroWinklerSimilarity("My Gym Children's Fitness
Center", "My Gym. Childrens Fitness"), 0.0d);
-        assertEquals(0.88d, StringUtils.getJaroWinklerSimilarity("PENNSYLVANIA", "PENNCISYLVNIA"),
0.0d);
-        assertEquals(0.63d, StringUtils.getJaroWinklerSimilarity("Haus Ingeborg", "Ingeborg
Esser"), 0.0d);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testGetJaroWinklerSimilarity_NullNull() throws Exception {
-        StringUtils.getJaroWinklerSimilarity(null, null);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testGetJaroWinklerSimilarity_StringNull() throws Exception {
-        StringUtils.getJaroWinklerSimilarity(" ", null);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testGetJaroWinklerSimilarity_NullString() throws Exception {
-        StringUtils.getJaroWinklerSimilarity(null, "clear");
-    }
-
-    @Test
     public void testGetFuzzyDistance() throws Exception {
         assertEquals(0, StringUtils.getFuzzyDistance("", "", Locale.ENGLISH));
         assertEquals(0, StringUtils.getFuzzyDistance("Workshop", "b", Locale.ENGLISH));


Mime
View raw message