diff --git a/memory.py b/memory.py index b5989da..bac5b69 100644 --- a/memory.py +++ b/memory.py @@ -55,7 +55,8 @@ We define a similarity measure on sets which counts the number of elements they have in common """ def scalar(a, b): - return len(a.intersection(b))/sqrt(len(a)*len(b)) + sizeProduct = len(a)*len(b) + return len(a.intersection(b))/sqrt(sizeProduct) if sizeProduct > 0 else 0 def find_best_quote(db, user_input): indexed_input = index(user_input)