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.4K 次下载
更新时间 2013/8/19

查看许可证

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.

Examples:

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

i =

[4]

d =

2

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

i =

[6] [3]

d =

1 5

>>

引用格式

Brandon Kuczenski (2024). Find nearest-matching string from a set (https://www.mathworks.com/matlabcentral/fileexchange/36981-find-nearest-matching-string-from-a-set), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2011b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.2.0.0

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

1.1.0.0

Add link to strdist.m

1.0.0.0