original_docstring: Find the Levenshtein distance between two strings.
docstring: Find the Levenshtein distance between two strings.
docstring_tokens: Find the Levenshtein distance between two strings .
code: def _levenshtein_distance(first, second):
      """Find the Levenshtein distance between two strings."""
      if len(first) > len(second):
          first, second = second, first
      if len(second) == 0:
          return len(first)
      first_length = len(first) + 1
      second_length = len(second) + 1
      distance_matrix = np.zeros((first_length, second_length), 'd')
      for i in range(first_length):
          distance_matrix[i, 0] = i
      for j in range(second_length):
          distance_matrix[0, j]=j
      for i in xrange(1, first_length):
          for j in range(1, second_length):
              deletion = distance_matrix[i-1, j] + 1
              insertion = distance_matrix[i, j-1] + 1
              substitution = distance_matrix[i-1, j-1]
              if first[i-1] != second[j-1]:
                  substitution += 1
              distance_matrix[i, j] = min(insertion, deletion, substitution)
      return distance_matrix[first_length-1, second_length-1]
code_tokens: def _levenshtein_distance ( first , second ) : if len ( first ) > len ( second ) : first , second = second , first if len ( second ) == 0 : return len ( first ) first_length = len ( first ) + 1 second_length = len ( second ) + 1 distance_matrix = np . zeros ( ( first_length , second_length ) , 'd' ) for i in range ( first_length ) : distance_matrix [ i , 0 ] = i for j in range ( second_length ) : distance_matrix [ 0 , j ] = j for i in xrange ( 1 , first_length ) : for j in range ( 1 , second_length ) : deletion = distance_matrix [ i - 1 , j ] + 1 insertion = distance_matrix [ i , j - 1 ] + 1 substitution = distance_matrix [ i - 1 , j - 1 ] if first [ i - 1 ] != second [ j - 1 ] : substitution += 1 distance_matrix [ i , j ] = min ( insertion , deletion , substitution ) return distance_matrix [ first_length - 1 , second_length - 1 ]
short_docstring: Find the Levenshtein distance between two strings.
short_docstring_tokens: Find the Levenshtein distance between two strings .
comment: """Find the Levenshtein distance between two strings."""