diff --git a/memory.py b/memory.py index 3a283b8..88216fc 100644 --- a/memory.py +++ b/memory.py @@ -1,5 +1,6 @@ import csv import json +from math import sqrt WORD_THRESHOLD = 4 @@ -52,7 +53,7 @@ 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)) + return len(a.intersection(b))/sqrt(len(a)*len(b)) def find_best_quote(db, user_input): indexed_input = index(user_input)