Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_stats(arr, title):
data_similarities = []
num = 1
for i in range(len(arr) - 2):
for j in range(i + 1, len(arr) - 1):
num += 1
print('iteration ', num, ' of ', ( len(arr) * (len(arr) - 1)))
data_similarities.append(textdistance.damerau_levenshtein.normalized_distance(arr[i], arr[j]))
np.save(title+'.npy', data_similarities)
#print_stats(data_similarities, title)
def other_distance(s1, s2):
return [textdistance.hamming.normalized_similarity(s1, s2),
textdistance.mlipns.normalized_similarity(s1, s2),
textdistance.damerau_levenshtein.normalized_similarity(s1, s2),
textdistance.strcmp95.normalized_similarity(s1, s2),
textdistance.needleman_wunsch.normalized_similarity(s1, s2),
textdistance.gotoh.normalized_similarity(s1, s2),
textdistance.smith_waterman.normalized_similarity(s1, s2),
textdistance.ratcliff_obershelp.normalized_similarity(s1, s2)]
return list(filter(lambda t: textdistance.damerau_levenshtein.distance(t, term) <= 2, dictionary))