edge case where union is 0 for jaccard
Browse files- logmetric.py +3 -0
logmetric.py
CHANGED
@@ -104,6 +104,9 @@ class LogMetric(evaluate.Metric):
|
|
104 |
def get_jaccard_similarity(self, set1, set2):
|
105 |
intersection = set1.intersection(set2)
|
106 |
union = set1.union(set2)
|
|
|
|
|
|
|
107 |
return len(intersection) / len(union)
|
108 |
|
109 |
# A score depending on the difference in length of two sentences
|
|
|
104 |
def get_jaccard_similarity(self, set1, set2):
|
105 |
intersection = set1.intersection(set2)
|
106 |
union = set1.union(set2)
|
107 |
+
if (len(union) == 0):
|
108 |
+
return 1.0
|
109 |
+
|
110 |
return len(intersection) / len(union)
|
111 |
|
112 |
# A score depending on the difference in length of two sentences
|