Skip to main content

Module levenshtein

Module levenshtein 

Source
Expand description

Levenshtein distance and ratio algorithms.

These are implemented from scratch — the library has zero external dependencies and this module must not introduce any.

§Algorithms

  • levenshtein_distance — the classic edit distance (insertions, deletions, substitutions each cost 1).
  • levenshtein_ratio — a normalised similarity score in [0.0, 1.0] derived from the distance. Two identical strings score 1.0; two completely different strings of maximum length score 0.0.

Functions§

levenshtein_distance
Compute the Levenshtein edit distance between two strings.
levenshtein_ratio
Compute the normalised Levenshtein similarity ratio between two strings.