The most important part of the algorithm is the line "levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;". This calculates the levenshtein distance between what you typed and valid commands, using different weights for different types of manipulations. In this case, 0 for swaps, 2 for substitutions, 1 for adds and 3 for deletes.
The most important part of the algorithm is the line "levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;". This calculates the levenshtein distance between what you typed and valid commands, using different weights for different types of manipulations. In this case, 0 for swaps, 2 for substitutions, 1 for adds and 3 for deletes.