Skip to content

Commit c684f39

Browse files
committed
Minor changes
1 parent 85bb691 commit c684f39

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

parse_data.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
parser = argparse.ArgumentParser()
1313
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')
1618
parser.add_argument('--train_ratio', default=1., type=float,
1719
help='ratio for train/val split')
1820
args = parser.parse_args()
@@ -44,18 +46,16 @@
4446
valid_cqas += cqas
4547

4648
if args.train_ratio == 1.:
47-
print('Writing dataset to file {}...'.format(args.outfile), end='')
49+
print('Writing to file {}...'.format(args.outfile), end='')
4850
with open(args.outfile, 'w') as fd:
4951
json.dump(train_cqas, fd)
5052
print('Done!')
5153
else:
5254
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:
5858
json.dump(train_cqas, fd)
59-
with open(valid_file, 'w') as fd:
59+
with open(args.outfile_valid, 'w') as fd:
6060
json.dump(valid_cqas, fd)
6161
print('Done!')

0 commit comments

Comments
 (0)