-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluation.py
48 lines (43 loc) · 1.38 KB
/
evaluation.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
import argparse
import logging
import yaml
from pathlib import Path
from tasks import task_mapping
from gensim_loader import VectorLoader
from metrics import metrics
from cli_logger import CLILogger
# logging.basicConfig(level=logging.INFO)
def main(args):
"""
args contains the path to the task configuration as well as embedding file.
:param args:
:return:
"""
gensim_loader = VectorLoader(args.embedding_file)
with open(args.task_config, 'r') as stream:
data_loaded = yaml.safe_load(stream)
tasks = [*data_loaded]
for task_name in tasks:
logging.info((f'Execute task: {task_name}'))
task_properties = data_loaded[task_name]
task_class = task_mapping[task_properties['type']]
source = task_properties['source']
with Path(source['path']).open(encoding="utf8") as f:
task = task_class(task_name, f, metrics[task_properties['metric']], gensim_loader, source, True)
with CLILogger(task):
print(task())
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--task-config',
type=Path,
help='Path to the config file',
required=True
)
parser.add_argument(
"--embedding-file",
type=Path,
help="Path to the embedding vector file",
required=True
)
main(parser.parse_args())