Skip to content

Commit a1d1aee

Browse files
authored
[neural search][fix bug of evaluate.py] (#7832)
* [fix][fix bug of evaluate.py] * Update evaluate.py * Update evaluate.py
1 parent ee4b9dd commit a1d1aee

File tree

1 file changed

+21
-9
lines changed
  • applications/neural_search/recall/in_batch_negative

1 file changed

+21
-9
lines changed

applications/neural_search/recall/in_batch_negative/evaluate.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,29 @@
1313
# limitations under the License.
1414

1515
import argparse
16+
import time
1617

1718
import numpy as np
1819

19-
import time
20-
2120
parser = argparse.ArgumentParser()
22-
parser.add_argument("--similar_text_pair", type=str,
23-
default='', help="The full path of similar pair file")
24-
parser.add_argument("--recall_result_file", type=str,
25-
default='', help="The full path of recall result file")
26-
parser.add_argument("--recall_num", type=int, default=10,
27-
help="Most similar number of doc recalled from corpus per query")
21+
parser.add_argument(
22+
"--similar_text_pair",
23+
type=str,
24+
default="",
25+
help="The full path of similar pair file",
26+
)
27+
parser.add_argument(
28+
"--recall_result_file",
29+
type=str,
30+
default="",
31+
help="The full path of recall result file",
32+
)
33+
parser.add_argument(
34+
"--recall_num",
35+
type=int,
36+
default=10,
37+
help="Most similar number of doc recalled from corpus per query",
38+
)
2839

2940

3041
args = parser.parse_args()
@@ -62,7 +73,6 @@ def recall(rs, N=10):
6273
with open(args.recall_result_file, "r", encoding="utf-8") as f:
6374
relevance_labels = []
6475
for index, line in enumerate(f):
65-
6676
if index % args.recall_num == 0 and index != 0:
6777
rs.append(relevance_labels)
6878
relevance_labels = []
@@ -73,6 +83,8 @@ def recall(rs, N=10):
7383
else:
7484
relevance_labels.append(0)
7585

86+
rs.append(relevance_labels)
87+
7688
recall_N = []
7789
recall_num = [1, 5, 10, 20, 50]
7890
for topN in recall_num:

0 commit comments

Comments
 (0)