|
11 | 11 |
|
12 | 12 | parser = argparse.ArgumentParser()
|
13 | 13 | parser.add_argument('data', type=str, help='Path to the dataset file')
|
14 |
| - parser.add_argument('--outfile', default='data/tmp.json', type=str, |
15 |
| - help='Desired path to output json') |
| 14 | + parser.add_argument('--outfile', default='data/train_parsed.json', |
| 15 | + type=str, help='Desired path to output train json') |
| 16 | + parser.add_argument('--outfile_valid', default='data/valid_parsed.json', |
| 17 | + type=str, help='Desired path to output valid json') |
16 | 18 | parser.add_argument('--train_ratio', default=1., type=float,
|
17 | 19 | help='ratio for train/val split')
|
18 | 20 | args = parser.parse_args()
|
|
44 | 46 | valid_cqas += cqas
|
45 | 47 |
|
46 | 48 | if args.train_ratio == 1.:
|
47 |
| - print('Writing dataset to file {}...'.format(args.outfile), end='') |
| 49 | + print('Writing to file {}...'.format(args.outfile), end='') |
48 | 50 | with open(args.outfile, 'w') as fd:
|
49 | 51 | json.dump(train_cqas, fd)
|
50 | 52 | print('Done!')
|
51 | 53 | else:
|
52 | 54 | print('Train/Val ratio is {}'.format(len(train_cqas) / len(valid_cqas)))
|
53 |
| - train_file = 'train_{}'.format(args.outfile) |
54 |
| - valid_file = 'valid_{}'.format(args.outfile) |
55 |
| - print('Writing datasets to files {}, {}...'.format(train_file, |
56 |
| - valid_file), end='') |
57 |
| - with open(train_file, 'w') as fd: |
| 55 | + print('Writing to files {}, {}...'.format(args.outfile, |
| 56 | + args.outfile_valid), end='') |
| 57 | + with open(args.outfile, 'w') as fd: |
58 | 58 | json.dump(train_cqas, fd)
|
59 |
| - with open(valid_file, 'w') as fd: |
| 59 | + with open(args.outfile_valid, 'w') as fd: |
60 | 60 | json.dump(valid_cqas, fd)
|
61 | 61 | print('Done!')
|
0 commit comments