-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.py
49 lines (35 loc) · 1.43 KB
/
controller.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
import sys
import logging.config
import argparse
import spacy
from collections import namedtuple
import detector_main
from transformation import transformation_main as transformation
logging.config.fileConfig(fname='log.config', disable_existing_loggers=False)
log = logging.getLogger(__name__)
Test = namedtuple('Test', ['file', 'header', 'steps'])
Step = namedtuple('Step', ['action', 'reactions'])
def run_code(mode):
# log.info(f'spaCy model: {model_name[0]}')
#nlp = create_pipeline(str(model_name[0]))
if mode == 'all' or mode == 'detect':
detector_main.detection_runner(log)
if mode == 'all' or mode == 'transform':
log.info('Starting transformation...')
transformation.transformation_runner(log)
log.info('FINISHED TRANSFORMATION.')
# breakpoint()
# def create_pipeline(model_name):
# # breakpoint()
# nlp = spacy.load(model_name)
# lang = nlp.meta['lang']
# name = nlp.meta['name']
# model_name = lang + '_' + name
# # log.info(f'spaCy model: {model_name}')
# return nlp
parser = argparse.ArgumentParser()
# parser.add_argument('--model', choices=['en_core_web_lg', 'en_core_web_trf', 'en_core_web_sm'], default='en_core_web_lg', nargs=1, help='Choose the model name')
parser.add_argument('--mode', choices=['all', 'transform', 'detect'], default='transform', nargs=1, help='Choose the mode of execution')
mode = sys.argv[2]
nlp = run_code(mode)
model_name = mode