"Did you mean" in git

I want to write the "Did you mean" algorithm.
I have a set of words (e.g. like git commands like pull, push, clone).
I need to give suggestions when users enter a word from a set of words.
All of the above details are the prerequisites of my question :)

"Do you mean" in git

I want to copy;) the code used in git to implement the "Did you mean" algorithm to accomplish my task.
Do you know the location of the git-source file containing the "you mean" algorithm?

+4
source share
2 answers

The corresponding code is in levenshtein.c (changing the distance) and help.c (cropping).

+9
source

Iarsmans already gave you a link to the implementation of the algorithm in git, but if you want to read something about the theory, you can read to edit the distance and the distance of Levenshtein from wikipedia.

Simply put, for the editing distance algorithm, the goal is to calculate - a given set of basic editing operations by the type of data you are working on (lines in your case) - the minimum number of corrections so that one value (line) is identical to another.

+2
source

Source: https://habr.com/ru/post/1401986/


All Articles