original_docstring: Calculates the Levenshtein distance between a and b.  Taken from wikisource http://en.wikisource.org/wiki/Levenshtein_distance#Python attributed to Magnus Lie Hetland 
docstring: Calculates the Levenshtein distance between a and b.
docstring_tokens: Calculates the Levenshtein distance between a and b .
code: def distance(a,b):
      "Calculates the Levenshtein distance between a and b.  Taken from wikisource http://en.wikisource.org/wiki/Levenshtein_distance#Python attributed to Magnus Lie Hetland "
      n, m = len(a), len(b)
      if n > m:
          # Make sure n <= m, to use O(min(n,m)) space
          a,b = b,a
          n,m = m,n
          
      current = range(n+1)
      for i in range(1,m+1):
          previous, current = current, [i]+[0]*n
          for j in range(1,n+1):
              add, delete = previous[j]+1, current[j-1]+1
              change = previous[j-1]
              if a[j-1] != b[i-1]:
                  change = change + 1
              current[j] = min(add, delete, change)
              
      return current[n]
code_tokens: def distance ( a , b ) : n , m = len ( a ) , len ( b ) if n > m : a , b = b , a n , m = m , n current = range ( n + 1 ) for i in range ( 1 , m + 1 ) : previous , current = current , [ i ] + [ 0 ] * n for j in range ( 1 , n + 1 ) : add , delete = previous [ j ] + 1 , current [ j - 1 ] + 1 change = previous [ j - 1 ] if a [ j - 1 ] != b [ i - 1 ] : change = change + 1 current [ j ] = min ( add , delete , change ) return current [ n ]
short_docstring: Calculates the Levenshtein distance between a and b.
short_docstring_tokens: Calculates the Levenshtein distance between a and b .
comment: "Calculates the Levenshtein distance between a and b.  Taken from wikisource http://en.wikisource.org/wiki/Levenshtein_distance#Python attributed to Magnus Lie Hetland "$SEP$# Make sure n <= m, to use O(min(n,m)) space