brian920128 commited on
Commit
36ed57b
1 Parent(s): 5d8c50a

Please enter the commit message for your changes. Lines starting

Files changed (1) hide show
  1. doc_retrieve_metrics.py +13 -6
doc_retrieve_metrics.py CHANGED
@@ -64,10 +64,14 @@ def calculate_precision(
64
  if len(d) == 0:
65
  continue
66
 
67
- predicted_pages = predictions[i]
68
- hits = predicted_pages.intersection(d)
69
- if len(predicted_pages) != 0:
70
- precision += len(hits) / len(predicted_pages)
 
 
 
 
71
 
72
  count += 1
73
 
@@ -85,8 +89,11 @@ def calculate_recall(
85
  if len(d) == 0:
86
  continue
87
 
88
- predicted_pages = predictions[i]
89
- hits = predicted_pages.intersection(d)
 
 
 
90
  recall += len(hits) / len(d)
91
 
92
  count += 1
 
64
  if len(d) == 0:
65
  continue
66
 
67
+ predicted_titles = predictions[i]
68
+ hits = 0
69
+ for title in predicted_titles:
70
+ if title in d:
71
+ hits += 1
72
+
73
+ if len(predicted_titles) != 0:
74
+ precision += len(hits) / len(predicted_titles)
75
 
76
  count += 1
77
 
 
89
  if len(d) == 0:
90
  continue
91
 
92
+ predicted_titles = predictions[i]
93
+ hits = 0
94
+ for title in predicted_titles:
95
+ if title in d:
96
+ hits += 1
97
  recall += len(hits) / len(d)
98
 
99
  count += 1