astring
astring copied to clipboard
Add edit distance API.
This has been c&p too much times.
(** {1:suggesting Suggesting} *)
val edit_distance : string -> string -> int
(** [edit_distance s0 s1] is the number of single byte edits (insertion,
deletion, substitution) that are needed to change [s0] into [s1]. *)
val suggest : ?dist:int -> string list -> string -> string list
(** [suggest ~dist candidates s] are the elements of [candidates]
whose {{!edit_distance}edit distance} is the smallest to [s] and
at most at distance [dist] of [s] (defaults to [2]). *)