Find nearest-matching string from a set

Computes shortest distance between a key string and a set of strings to find the nearest match.
1,3K descargas
Actualizado 19 ago 2013

Ver licencia

Uses a modified Vagner-Fischer algorithm to find the Levenshtein distance between each pair of strings. Progressively narrows the threshold to equal the distance of the best match found so far, reducing run time.

Updated to correct the algorithm. (sorry!)

Optional behaviors include an upper-bound threshold distance, detect first or multiple matches of equal distance, case insensitivity.


>> [i,d]=strnearest({'first string'},{'string 2','abcdefgh','FURSrtd','firststring'})

i =


d =


>> [i,d]=strnearest({'1','first string'},{'string 2','abcdefgh','1st string','FURSrtd','seconaaad string','2'})

i =

[6] [3]

d =

1 5


Citar como

Brandon Kuczenski (2024). Find nearest-matching string from a set (, MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2011b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Más información sobre Characters and Strings en Help Center y MATLAB Answers.

Inspirado por: Calculation of distance between strings

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión

Updated to correct an error in the code and to add working examples to the description.

Add link to strdist.m