File Exchange

image thumbnail

edit distances

version (12.4 KB) by Boris Schauerte
Edit distances for strings and key lists (i.e. cell arrays of strings or other elements).

1 Download

Updated 17 Aug 2015

From GitHub

View Version History

View license on GitHub

This package provides implementations of the Levenshtein, Damerau-
Levenshtein, and weighted edit distance for strings as well as key lists
(i.e. cell arrays of strings or arbitrary other elements).
This code is part of the work described in [1]. In [1], edit distances are
applied to match linguistic descriptions that occur when referring to objects
(in order to achieve joint attention in spoken human-robot / human-human

[1] B. Schauerte, G. A. Fink, "Focusing Computational Visual Attention
in Multi-Modal Human-Robot Interaction," in Proc. ICMI, 2010.


Cite As

Boris Schauerte (2021). edit distances (, GitHub. Retrieved .

Comments and Ratings (3)


I also get incorrect l-d distances when transpositions are involved. Error is on line 76 of edit_distance_damerau.m, which should read:

d(i-2,j-2) + cost, ...

Note the " + cost" was missing. There is a similar error in the edit_distance_damerau_keylist.m file

forkandwait w

In the transposition part, "d(i-2,j-2)" should be "d(i-1,j-1)", otherwise cumulative costs don't carry forward.

forkandwait w

I get incorrect values for a swap with levenshtein-damerau:

14> edit_distance_damerau('smtih', 'smith')
ans = 0

ans should be 1, with the swapping of "ti"

Otherwise nice code -- I am using it to understand this algorithm

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!