We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I believe the two strings "CA" and "ABC" technically only require two changes under Damerau-Levenshtein distance: Transposition + Insertion.
CA -> AC -> ABC
This library returns "3" as the number of changes. Is this correct?
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. It looks like I misimplemented OSA instead of Damerau–Levenshtein distance?
https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance
Sorry, something went wrong.
I'm still not sure this case of swapping is well-covered by the spec. Here is the test I ran:
func TestDL(t *testing.T) { var table = []struct { A string B string Score int }{ {"", "", 0}, {" ", " ", 0}, {"ABC", "ABC", 0}, {"A", "B", 1}, {"A", "", 1}, {"", "B", 1}, {"c", "cat", 2}, {"a", "hot", 3}, {"CA", "ABC", 3}, // or 2? "CA" -> "AC" -> "ABC" {"aabc", "abc", 1}, {"abcc", "abc", 1}, {"abc", "bac", 1}, {"abc", "abcc", 1}, {"abc", "aabc", 1}, {"abcdef", "poiu", 6}, {"teh", "the", 1}, {"tets", "test", 1}, {"fuor", "four", 1}, {"kitten", "sitting", 3}, {"Saturday", "Sunday", 3}, {"rosettacode", "raisethysword", 8}, } for _, row := range table { score := textdistance.DamerauLevenshteinDistance(row.A, row.B) if score != row.Score { t.Errorf("Textdistance: Expected score=%d, got score=%d (A='%s', B='%s')", row.Score, score, row.A, row.B) } } }
No branches or pull requests
I believe the two strings "CA" and "ABC" technically only require two changes under Damerau-Levenshtein distance: Transposition + Insertion.
This library returns "3" as the number of changes. Is this correct?
The text was updated successfully, but these errors were encountered: