-
Notifications
You must be signed in to change notification settings - Fork 41
/
binarize.py
27 lines (21 loc) · 913 Bytes
/
binarize.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
import importlib
import pathlib
import click
import preprocessing
from utils.config_utils import read_full_config, print_config
@click.command(help='Process the raw dataset into binary dataset')
@click.option('--config', required=True, metavar='FILE', help='Path to the configuration file')
def binarize(config):
config = pathlib.Path(config)
config = read_full_config(config)
print_config(config)
binarizer_cls = config['binarizer_cls']
pkg = ".".join(binarizer_cls.split(".")[:-1])
cls_name = binarizer_cls.split(".")[-1]
binarizer_cls = getattr(importlib.import_module(pkg), cls_name)
assert issubclass(binarizer_cls, preprocessing.BaseBinarizer), \
f'Binarizer class {binarizer_cls} is not a subclass of {preprocessing.BaseBinarizer}.'
print("| Binarizer: ", binarizer_cls)
binarizer_cls(config=config).process()
if __name__ == '__main__':
binarize()