std.edit

Provides functions to compute and interpret edit distance.

  • Author: Edward Jones
  • Date: 2021-09-24

Source file

closest

Find the closest string to a given one from a list of strings.

  • Param s: A source string
  • Param ts: A list of strings

Returns: The t in ts which is closest to s

closest = (s, ts) -> ...

edit_distance

Compute the edit distance between two strings.

  • Param u: A string
  • Param v: Another string

Returns: The edit distance between u and v

edit_distance = (u, v) -> ...

unknown_x_msg

Create a suggestion message when an incorrect value was supplied which should have been in a list of options.

  • Param x: The name of the type of v
  • Param v: The incorrect value given
  • Param vs: The list of valid values of which v should have been a member

Returns: A user-friendly message which suggests the u in vs which is closest to v if it is not too distant

unknown_x_msg = (x, v, vs) -> ...