def edit_distance(s1, s2, substitution_cost=1, transpositions=False):
 len1 = len(s1)
 len2 = len(s2)
 lev = _edit_dist_init((len1 + 1), (len2 + 1))
 for i in range(len1):
  for j in range(len2):
   _edit_dist_step(lev, (i + 1), (j + 1), s1, s2, substitution_cost=substitution_cost, transpositions=transpositions)
 return lev[len1][len2]

def edit_distance ( s1 , s2 , substitution_cost = 1 , transpositions = False ) : len1 = len ( s1 ) len2 = len ( s2 ) lev = _edit_dist_init ( ( len1 + 1 ) , ( len2 + 1 ) ) for i in range ( len1 ) : for j in range ( len2 ) : _edit_dist_step ( lev , ( i + 1 ) , ( j + 1 ) , s1 , s2 , substitution_cost = substitution_cost , transpositions = transpositions ) return lev [ len1 ] [ len2 ]
calculate the levenshtein edit-distance between two strings .