mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-07 18:48:39 +00:00
Applying Eli Lindsey's patch to Yaniv Kunda's report in LANG-936 that StringUtils.getLevensteinDistance(String, String, int) gave the wrong answer when the int threshold is near Integer.MAX_VALUE
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1560275 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a8595f1a5
commit
8cd2339a97
@ -22,6 +22,7 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<release version="3.3" date="TBA" description="Bugfix and Feature release">
|
<release version="3.3" date="TBA" description="Bugfix and Feature release">
|
||||||
|
<action issue="LANG-936" type="fix" dev="bayard" due-to="Yaniv Kunda, Eli Lindsey">StringUtils.getLevenshteinDistance with too big of a threshold returns wrong result</action>
|
||||||
<action issue="LANG-943" type="fix" dev="kinow">Test DurationFormatUtilsTest.testEdgeDuration fails in JDK 1.6, 1.7 and 1.8, BRST time zone</action>
|
<action issue="LANG-943" type="fix" dev="kinow">Test DurationFormatUtilsTest.testEdgeDuration fails in JDK 1.6, 1.7 and 1.8, BRST time zone</action>
|
||||||
<action issue="LANG-613" type="fix" dev="mbenson">ConstructorUtils.getAccessibleConstructor() Does Not Check the Accessibility of Enclosing Classes</action>
|
<action issue="LANG-613" type="fix" dev="mbenson">ConstructorUtils.getAccessibleConstructor() Does Not Check the Accessibility of Enclosing Classes</action>
|
||||||
<action issue="LANG-951" type="fix" dev="britter" due-to="Sebastian Götz">Fragments are wrong by 1 day when using fragment YEAR or MONTH</action>
|
<action issue="LANG-951" type="fix" dev="britter" due-to="Sebastian Götz">Fragments are wrong by 1 day when using fragment YEAR or MONTH</action>
|
||||||
|
@ -6938,7 +6938,7 @@ distance is O(nm), but a bound of k allows us to reduce it to O(km) time by only
|
|||||||
|
|
||||||
// compute stripe indices, constrain to array size
|
// compute stripe indices, constrain to array size
|
||||||
final int min = Math.max(1, j - threshold);
|
final int min = Math.max(1, j - threshold);
|
||||||
final int max = Math.min(n, j + threshold);
|
final int max = (j > Integer.MAX_VALUE - threshold) ? n : Math.min(n, j + threshold);
|
||||||
|
|
||||||
// the stripe may lead off of the table if s and t are of different sizes
|
// the stripe may lead off of the table if s and t are of different sizes
|
||||||
if (min > max) {
|
if (min > max) {
|
||||||
|
@ -1974,6 +1974,14 @@ public void testGetLevenshteinDistance_StringStringInt() {
|
|||||||
assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz", "hippo",8) );
|
assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz", "hippo",8) );
|
||||||
assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo",1) );
|
assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo",1) );
|
||||||
|
|
||||||
|
assertEquals(1, StringUtils.getLevenshteinDistance("frog", "fog", Integer.MAX_VALUE) );
|
||||||
|
assertEquals(3, StringUtils.getLevenshteinDistance("fly", "ant", Integer.MAX_VALUE) );
|
||||||
|
assertEquals(7, StringUtils.getLevenshteinDistance("elephant", "hippo", Integer.MAX_VALUE) );
|
||||||
|
assertEquals(7, StringUtils.getLevenshteinDistance("hippo", "elephant", Integer.MAX_VALUE) );
|
||||||
|
assertEquals(8, StringUtils.getLevenshteinDistance("hippo", "zzzzzzzz", Integer.MAX_VALUE) );
|
||||||
|
assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz", "hippo", Integer.MAX_VALUE) );
|
||||||
|
assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo", Integer.MAX_VALUE) );
|
||||||
|
|
||||||
// exceptions
|
// exceptions
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user