-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp2_evaluation.py
More file actions
36 lines (29 loc) · 1021 Bytes
/
exp2_evaluation.py
File metadata and controls
36 lines (29 loc) · 1021 Bytes
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
from mallm.evaluation.evaluator import Evaluator
import glob
import os
import json
import fire
import logging
import nltk
nltk.download('punkt')
logger = logging.getLogger("mallm")
original_print = print
def main():
input_files = glob.glob(os.path.join("exp2/out/", "*.json"))
with open("metrics.json", "r") as metrics_file:
metrics = json.load(metrics_file)
for input_file in input_files:
if "-eval" in input_file or "-stats" in input_file or input_file+"-eval" in input_files:
continue
logger.info("Evaluating " + input_file)
m = []
for metric in metrics.keys():
if metric in input_file:
m = metrics[metric]
if "baseline" in input_file:
evaluator = Evaluator(input_file_path=input_file, metrics=m, extensive=False)
else:
evaluator = Evaluator(input_file_path=input_file, metrics=m, extensive=True)
evaluator.process()
if __name__ == "__main__":
fire.Fire(main)