Skip to content

Instantly share code, notes, and snippets.

View brandonrobertz's full-sized avatar

Brandon Roberts brandonrobertz

View GitHub Profile
@brandonrobertz
brandonrobertz / damerau_levenshtein_distance.py
Last active December 9, 2021 20:44 — forked from pombredanne/damlevdist-improved.py
Damerau-Levenshtein edit distance Python 3
# Damerau-Levenshtein edit distance implementation for Python 3
# Python 3 compatable, forked from: https://gist.github.com/pombredanne/0d83ad58f45986ddeb0917266e106be0
# Which was based on: https://gist.github.com/badocelot/5327427
# Which was based on pseudocode from Wikipedia: https://en.wikipedia.org/wiki/Damerau-Levenshtein_distance
# Possible improvement by treating 1 addition + 1 deletion = 1 substitution
# between transposed characters:
#
# Damerau-Levenshtein distance for "abcdef" and "abcfad" = 3:
# 1. substitute "d" for "f"