Skip to content

fix: wrong transposition calculation in unrestricted damerau-levenshtein - #781

Open
nadalaba wants to merge 1 commit into
NaturalNode:masterfrom
nadalaba:fix-damerau
Open

fix: wrong transposition calculation in unrestricted damerau-levenshtein#781
nadalaba wants to merge 1 commit into
NaturalNode:masterfrom
nadalaba:fix-damerau

Conversation

@nadalaba

Copy link
Copy Markdown
console.log(natural.DamerauLevenshteinDistance("ax", "axx")); // output: 0

Currently, any repeated symbol in the columns will be regarded as a window for transposition (when it shouldn't).

So if on the current row we have an "x" symbol, then after the column of the first "x", lastRowMap will record the "x" in the rows, making the second "x" in the columns consider that lone "x" in the rows its match.

const lastRowMatch = lastRowMap[targetElement]

That "x" in the rows, should not be recorded for matching with symbols from the columns until after the row is finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant