Fix a bug for calculating the edit distance
Change-Id: I4c2cd102c258ccdb2de18c53901f91c0f7c7a986main
parent
add3e05379
commit
a6f2fcdcea
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue