-
Notifications
You must be signed in to change notification settings - Fork 0
/
predict_all.py
51 lines (40 loc) · 1.49 KB
/
predict_all.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
43
44
45
46
47
48
49
50
51
import os
import subprocess
from constants import ALL_MODEL_NAMES, EVALUATION_NAME_TO_FILEPATH
def main():
for index, model_name in enumerate(ALL_MODEL_NAMES):
print(f"\n\nWorking on model {index+1}/{len(ALL_MODEL_NAMES)} [{model_name}].")
for (
evaluation_name,
evaluation_file_path,
) in EVALUATION_NAME_TO_FILEPATH.items():
model_with_data_name = model_name
model_with_data_name += "-"
model_with_data_name += (
evaluation_name.replace("_dev", "").replace("_test", "").replace(
"_cs", ""
).replace("_bpb", "").replace("_", "-")
)
model_path = f"StonyBrookNLP/{model_with_data_name}"
output_file_path = os.path.join(
"predictions", model_with_data_name + "__" + evaluation_name + ".jsonl"
)
command = " ".join(
[
"python",
"predict.py",
model_path,
evaluation_file_path,
output_file_path,
]
)
if os.path.exists(output_file_path):
print(
f"The prediction file path {output_file_path} already exists. "
f"So skipping prediction."
)
continue
print(command)
subprocess.call(command.split())
if __name__ == "__main__":
main()