-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbulk_anyburl_hits_analyser.py
28 lines (25 loc) · 1.17 KB
/
bulk_anyburl_hits_analyser.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
from argparse import ArgumentParser
from random import randint
import os
import divide
import anyburl_hits_analyser
# Read the argument from command line
parser = ArgumentParser()
parser.add_argument('--predictions',help="Parent folder with the dataset folders with the predictions")
parser.add_argument('--rank-threshold',help="Rank chosen for ordering")
parser.add_argument('--examples-folder',help="Folder where all examples are; the structure must be as usual")
parser.add_argument('--output',help="File where we store the result")
args = parser.parse_args()
# Ensure that input is a valid folder
assert os.path.exists(args.predictions)
assert os.path.exists(args.examples_folder)
assert os.path.exists(args.output)
# Read the corresponding files
for dataset in os.listdir(args.predictions):
try:
predictions_file = args.predictions + '/' + dataset + '/alpha-10'
examples_path = args.examples_folder + '/' + dataset + '/test'
output_file = args.output + '/' + dataset + '.txt'
anyburl_hits_analyser.analyse(predictions_file, args.rank_threshold, examples_path, output_file)
except:
print("Error for dataset {}".format(dataset))