Fix a bug for calculating the edit distance

Change-Id: I4c2cd102c258ccdb2de18c53901f91c0f7c7a986
main
satok 2011-08-26 19:30:56 +09:00
parent add3e05379
commit a6f2fcdcea
1 changed files with 1 additions and 1 deletions

View File

@ -490,7 +490,7 @@ inline static int editDistance(
const uint16_t cost = (ci == co) ? 0 : 1; const uint16_t cost = (ci == co) ? 0 : 1;
dp[(i + 1) * lo + (j + 1)] = min(dp[i * lo + (j + 1)] + 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)); 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])) { && co == Dictionary::toBaseLowerCase(input[i - 1])) {
dp[(i + 1) * lo + (j + 1)] = min( dp[(i + 1) * lo + (j + 1)] = min(
dp[(i + 1) * lo + (j + 1)], dp[(i - 1) * lo + (j - 1)] + cost); dp[(i + 1) * lo + (j + 1)], dp[(i - 1) * lo + (j - 1)] + cost);