-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.py
69 lines (55 loc) · 1.89 KB
/
generate.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import sys
import argparse
import configparser
from utils import initialize_logger
from data_generation.initialize import initialize_all
from data_generation.utils import \
get_common_data \
, get_bart_summary \
, get_lead_3_summary \
, get_ats_model_data \
, get_integration_data \
, change_format
information = ' '.join(sys.argv)
def main(*args, **kwargs):
parser = argparse.ArgumentParser()
parser.add_argument(
'-c', '--config'
, help='The path of config file'
, required=True
)
parser.add_argument(
'-g', '--gpu'
, help='The list of GPU IDs (Require if summarization method is bart)'
)
parser.add_argument(
'-cp', '--checkpoint_path'
, help='The path of checkpoint \
(Require if summarization method is bart)'
)
args = parser.parse_args()
config = configparser.ConfigParser()
config.read(args.config)
logger = initialize_logger(log_name=config.get('log', 'name'))
logger.info(f'\n\n\n\n{information}')
parameters = initialize_all(
config=config
, device_str=args.gpu
, checkpoint_path=args.checkpoint_path)
logger.info(f'Start to generate data.')
if parameters['task'] == 'legal_judgment_prediction':
if parameters['summarization'] == 'none':
get_common_data(parameters=parameters)
elif parameters['summarization'] == 'bart':
get_bart_summary(parameters)
elif parameters['summarization'] == 'lead_3':
get_lead_3_summary(parameters)
elif parameters['task'] == 'abstractive_text_summarization':
get_ats_model_data(parameters)
elif parameters['task'] == 'integration':
get_integration_data(parameters)
elif parameters['task'] == 'change_format':
change_format(parameters)
logger.info('Generate data successfully.')
if __name__ == '__main__':
main()