From a6f2fcdcea2e56aae08f73dc542be98f48d3995f Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 26 Aug 2011 19:30:56 +0900 Subject: [PATCH] Fix a bug for calculating the edit distance Change-Id: I4c2cd102c258ccdb2de18c53901f91c0f7c7a986 --- native/src/correction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/src/correction.cpp b/native/src/correction.cpp index ce4a869f0..5a0e608b8 100644 --- a/native/src/correction.cpp +++ b/native/src/correction.cpp @@ -490,7 +490,7 @@ inline static int editDistance( const uint16_t cost = (ci == co) ? 0 : 1; dp[(i + 1) * lo + (j + 1)] = min(dp[i * lo + (j + 1)] + 1, min(dp[(i + 1) * lo + j] + 1, dp[i * lo + j] + cost)); - if (ci == Dictionary::toBaseLowerCase(output[j - 1]) + if (i > 0 && j > 0 && ci == Dictionary::toBaseLowerCase(output[j - 1]) && co == Dictionary::toBaseLowerCase(input[i - 1])) { dp[(i + 1) * lo + (j + 1)] = min( dp[(i + 1) * lo + (j + 1)], dp[(i - 1) * lo + (j - 1)] + cost);