-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
49 lines (41 loc) · 1.55 KB
/
run.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
import logging
import hydra
from omegaconf import DictConfig
from src.dicts_and_contants.constants_GER import ConstantsGER
from src.dicts_and_contants.constants_EN import ConstantsEN
import src.dicts_and_contants.constants as constants
from src.dicts_and_contants.bias_lexica_GER import BiasLexicaGER
from src.dicts_and_contants.bias_lexica_EN import BiasLexicaEN
import src.dicts_and_contants.bias_lexica as bias_lexica
rootLogger = logging.getLogger()
consoleHandler = logging.StreamHandler()
rootLogger.addHandler(consoleHandler)
rootLogger = None
@hydra.main(config_path="conf", config_name="config")
def run(cfg: DictConfig):
mode = cfg.run_mode.name
print("Language = ", cfg.language)
# set language-specific constants
if cfg.language == "GER":
constants.constants = ConstantsGER()
bias_lexica.bias_lexica = BiasLexicaGER()
elif cfg.language == "EN":
constants.constants = ConstantsEN()
bias_lexica.bias_lexica = BiasLexicaEN()
print("Run mode", mode)
if mode == "data":
from src import create_dataset
create_dataset.main(cfg)
elif mode == "classifier":
from src import run_classifier
run_classifier.run(cfg, rootLogger)
elif mode == "generate":
from src.text_generator.run_text_generation import run_txt_generation
run_txt_generation(cfg)
elif mode == "eval_bias":
from src.run_bias_eval import run_bias_evaluation
run_bias_evaluation(cfg)
else:
print("Run mode not implemented. Typo?")
if __name__ == "__main__":
run()