Actions
Feature #10882
openProvide Levenshtein distance implementation as part of stdlib
Status:
Open
Assignee:
-
Target version:
-
Description
Levenshtein distance algorithm has been used by Rubygems, Bundler, did_you_mean and Rails and I think it's popular enough to provide it as part of Ruby's stdlib. It still seems a bit too high-level though, but definitely useful (e.g. adding "did you mean?" to rake).
API-wise, I would like to propose something like the following, but I'm totally open to hear the core team's opinions as I'm not sue if this is great.
require 'distance'
Distance.levenshtein(str1, str2)
It would also be interesting to have #distance
method on String
:
"word".distance("other")
which is implemented as:
def distance(str, algorithm = :levenshtein)
# calculate the distance here.
end
so it can allow to change the algorythm when we add more (e.g. Jaro–Winkler distance).
Actions
Like0
Like0Like0