1313# limitations under the License.
1414
1515import argparse
16+ import time
1617
1718import numpy as np
1819
19- import time
20-
2120parser = 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
3041args = 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