Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 87DA4109FA for ; Wed, 22 Jan 2014 08:20:35 +0000 (UTC) Received: (qmail 2718 invoked by uid 500); 22 Jan 2014 08:20:32 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 2266 invoked by uid 500); 22 Jan 2014 08:20:29 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 1707 invoked by uid 99); 22 Jan 2014 08:20:21 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jan 2014 08:20:21 +0000 Date: Wed, 22 Jan 2014 08:20:20 +0000 (UTC) From: "Henri Yandell (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (LANG-936) StringUtils.getLevenshteinDistance with too big of a threshold returns wrong result MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13878391#comment-13878391 ] Henri Yandell edited comment on LANG-936 at 1/22/14 8:20 AM: ------------------------------------------------------------- Thanks Yaniv + Eli :) svn ci -m "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" . Sending src/changes/changes.xml Sending src/main/java/org/apache/commons/lang3/StringUtils.java Sending src/test/java/org/apache/commons/lang3/StringUtilsTest.java Transmitting file data ... Committed revision 1560275. was (Author: bayard): Thanks Yanix + Eli :) svn ci -m "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" . Sending src/changes/changes.xml Sending src/main/java/org/apache/commons/lang3/StringUtils.java Sending src/test/java/org/apache/commons/lang3/StringUtilsTest.java Transmitting file data ... Committed revision 1560275. > StringUtils.getLevenshteinDistance with too big of a threshold returns wrong result > ----------------------------------------------------------------------------------- > > Key: LANG-936 > URL: https://issues.apache.org/jira/browse/LANG-936 > Project: Commons Lang > Issue Type: Bug > Components: lang.* > Affects Versions: 3.1 > Reporter: Yaniv Kunda > Priority: Minor > Fix For: 3.3 > > > StringUtils.getLevenshteinDistance(CharSequence s, CharSequence t, int threshold) specifies: > {quote} > {{Find the Levenshtein distance between two Strings if it's _+*less than or equal to*+_ a given threshold.}} > {quote} > When passing a threshold > *Integer.MAX_VALUE - max(s.length(), t.length())* the method always returns -1. > The simplest use case is passing *Integer.MAX_VALUE* (a common practice if one would want to find the min/max LD of a string to several other strings in an iterative fashion. > The code should be fixed to consider the threshold in relation to the source/target lengths, or alternatively the javadoc should be fixed to pronounce the current limit. -- This message was sent by Atlassian JIRA (v6.1.5#6160)