-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_mesure_results.py
44 lines (36 loc) · 1.15 KB
/
extract_mesure_results.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# extract mesure results of queries
from os import listdir
from os.path import join
import os
import docopt
def find_between( s, first, last ):
try:
start = s.index( first ) + len( first )
end = s.index( last, start )
return (s[start:end])
except ValueError:
return ("")
if __name__ == "__main__":
print("\n------Begin------\n")
args = docopt.docopt("""
Usage:
extract_mesure_results.py <evaluate_folder> <outputfolder> <mesure_to_extract>
""")
print (args)
print("{mesure} extraction ...".format(mesure=args["<mesure_to_extract>"]))
for f in listdir(args["<evaluate_folder>"]) :
eval_file=join(args["<evaluate_folder>"],f)
runf = open(eval_file,"r")
res=(runf.name).replace(args["<evaluate_folder>"],'')+"_queries_"+args["<mesure_to_extract>"]
print("res= "+res)
out=args["<outputfolder>"]+res
print(out)
results=open(out,"w")
lines = runf.readlines()
for l in lines :
if (args["<mesure_to_extract>"] in l) and ("all" not in l) and ("P_100" not in l):
req=l.split()[1]
val=l.split()[2]
results.write(req+"\t"+val+"\n")
print("Finished.")
print("result in : "+out)