def levenshtein_distance(w1, w2):
	"""
	Calculates the Levenshtein (minimum edit) distance between two words. This implementation is based on the one
	provided by Stavros Korokithakis ( https://www.stavros.io/posts/finding-the-levenshtein-distance-in-python/ ),
	licensed under BSD with Attribution. For questions concerning the original implementation, Stavros can be
	contacted via email at hi@stavros.io .

	Levenshtein Distance summary: https://en.wikipedia.org/wiki/Levenshtein_distance
	"""
	if len(w1) > len(w2): w1, w2 = w2, w1
	if len(w2) == 0: return len(w1)
	len_w1 = len(w1) + 1
	len_w2 = len(w2) + 1
	dist_matrix = [[0] * len_w2 for x in range(len_w1)]
	for i in range(len_w1): dist_matrix[i][0] = i
	for j in range(len_w2): dist_matrix[0][j] = j
	for i in range(1, len_w1):
		for j in range(1, len_w2):
			del_cost = dist_matrix[i-1][j] + 1
			ins_cost = dist_matrix[i][j-1] + 1
			sub_cost = dist_matrix[i-1][j-1]
			if w1[i-1] != w2[j-1]: sub_cost += 1
			dist_matrix[i][j] = min(ins_cost, del_cost, sub_cost)
	return dist_matrix[len_w1-1][len_w2-1]