REGISTER NOW: Brightway Spring School! 🇨🇦 Québec City (Canada) 🗓️ 20.-24. May 2024

bw2data.string_distance#

Module Contents#

Functions#

damerau_levenshtein(string_1, string_2)

Calculates the Damerau-Levenshtein distance between two strings.

bw2data.string_distance.damerau_levenshtein(string_1, string_2)[source]#

Calculates the Damerau-Levenshtein distance between two strings.

In addition to insertions, deletions and substitutions, Damerau-Levenshtein considers adjacent transpositions.

This version is based on an iterative version of the Wagner-Fischer algorithm.

Usage:

>>> damerau_levenshtein('kitten', 'sitting')
3
>>> damerau_levenshtein('kitten', 'kittne')
1
>>> damerau_levenshtein('', '')
0