Not levenhstein

Like levenshtein with difflib.

source_word = "apple"
word_list = ["apply", "aple", "banana", "orange", "applet"]

closest = cli2.closest(source_word, word_list)
print(f"The closest word to '{source_word}' is: {closest}")
cli2.notlevenshtein.closest(source_token, token_list)[source]

Finds the token in token_list with the shortest distance to source_token.

Parameters:
  • source_token – The source token (string).

  • token_list – A list of tokens (strings).

Returns:

The token with the shortest distance, or None if token_list is empty.

cli2.notlevenshtein.closest_path(path, paths)[source]

Find the closest path from paths.

LLM may output broken paths, this fixes them.

Parameters:
  • path – Path to find closest

  • paths – List of paths to search in.