Skip to content
Snippets Groups Projects
Commit a6f2fcdc authored by satok's avatar satok
Browse files

Fix a bug for calculating the edit distance

Change-Id: I4c2cd102c258ccdb2de18c53901f91c0f7c7a986
parent add3e053
No related branches found
No related tags found
No related merge requests found
...@@ -490,7 +490,7 @@ inline static int editDistance( ...@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment