emory-courses / computational-linguistics

Computational Linguistics.
90 stars 100 forks source link

Euclidean Distance #28

Open xxlin-haa opened 2 years ago

xxlin-haa commented 2 years ago

For 02/03 lecture, I'm not sure why we need to have this second line in euclidean function? Thank you.

def euclidean(x1: Dict[str, float], x2: Dict[str, float]) -> float: t = sum(((s1 - x2.get(term, 0)) 2 for term, s1 in x1.items())) t += sum((s2 2 for term, s2 in x2.items() if term not in x1)) return t