scores = []
if len(ft) == 0: return 0.0 // invalid length for first string
for x in second:
scores.append(max([_levenshtein_distance(x, y) for y in ft]))
s = np.sum(scores) / maxlen
return s
After Change
for o in n[:5]:
ft_1.add(o)
ft_2 = set() // all related words with second sentence
for x in second:
ft_2.add(x)
n, _ = nearby(x)