I want to write a "Did you mean" algorithm.
I have a set of words (Just like git commands such as pull, push, clone).
I need to give suggestions whenever users are entering a word out of the set of words.
All above details are background of my question :)
I want to copy ;) the code used in the git to implement 'Did you mean' algorithm to accomplish my task.
Do you know the location of the git-source-file containing the 'Did you mean' algorithm ?
The relevant code is in levenshtein.c
(edit distance computation) and help.c
(cutoff).
Iarsmans already gave you a link to the implementation of the algorithm in git, but if you wish to read something about the theory you may want to read the edit distance and Levenshtein distance pages on wikipedia.
To put it simply, for an edit distance algorithm, the aim is to calculate -- given a set of basic edit operations on the data type you're working on (strings in your case) -- the minimum number of edits to make one value (string) identical to the other one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With