Skip to content

Instantly share code, notes, and snippets.

View jlherren's full-sized avatar

Jean-Luc Herren jlherren

  • Zurich, Switzerland
  • 10:06 (UTC +02:00)
  • X @jlherren
View GitHub Profile
type DeliminatedDocument = {
text: string;
separator: "comma" | "tab";
type PlaintextDocument = {
text: string;
type WeirdPlaintextDocument = PlaintextDocument & {
jlherren /
Created February 19, 2020 16:10
Find Levenshtein distance between two strings and construct edit instructions to go from one string to the other
import numpy
def wagner_fisher(s: str, t: str):
Computes the Levenshtein distance between the two strings. Returns a tuple containing
the distance itself and also the entire matrix for further processing.
m, n = len(s), len(t)