-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is limit
and also it's broken
#13
Comments
Hm... Very good find. Thanks. I suppose it is meant to prevent very long and expensive computations. Imagine you have a large collection of strings, perhaps every word in a given language or DNA sequences. You want to filter only similar ones (for spell checking or something like that). So you may say that word is similar when the distance is no more than 4 steps. To optimize the process you want to set a limit - once a given string reaches fifth step you want to terminate the computation and move on. So I think the My quick idea is to return: {
steps: undefined,
similarity: undefined,
relative: undefined
} In this case very_long_array_of_words.filter((word) => {
return levenshtien(word, "nosorożec", 5).steps < 5
}) Also Would it be difficult to annotate it with TS? I think it should be possible: either But that's just a very quick idea. What do you think? What is your use case? |
I don't have a use case -- I was just looking at the code and was surprised to see an undocumented argument 🤷♂ I'll be happy to document the feature in the README as well as fix its behavior somehow (I think returning |
There seems to be an extra parameter,
limit
, that is allowed:node-damerau-levenshtein/index.js
Line 5 in 59cf148
Yet if you ever put in a number that is smaller than the total
steps
the method fails:e.g.
results in:
I can't figure out what it was meant to accomplish. 🤔
Perhaps remove it altogether?
The text was updated successfully, but these errors were encountered: