Skip to content

Commit aeee367

Browse files
authored
Update data_aug.py
1 parent c9a87f2 commit aeee367

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

applications/tools/data/data_aug/data_aug.py

+20-21
Original file line numberDiff line numberDiff line change
@@ -288,27 +288,26 @@ def choose_parser():
288288

289289

290290
if six.PY3:
291-
with open(input_file_path, encoding='UTF-8') as input_file:
292-
with open(input_file_path) as input_file:
293-
with open(output_file_path, 'w') as output_file:
294-
for i, l in enumerate(input_file.readlines()):
295-
parser = choose_parser()
296-
#print(parser.__name__ == "pos_replace_parser")
297-
if i % 1000 == 0:
298-
log.debug('parsing line %d' % i)
299-
print(l.strip(), file=output_file)
300-
301-
for k in range(args.aug_times):
302-
cols = l.strip().split('\t')
303-
for j in col_nums:
304-
if parser.__name__ == "pos_replace_parser":
305-
cols[j - 1] = parser(cols[j - 1], pos_dict[j - 1])
306-
counter[parser.__name__] += 1
307-
else:
308-
cols[j - 1] = parser(cols[j - 1])
309-
counter[parser.__name__] += 1
310-
new_line = '\t'.join(cols)
311-
print(new_line, file=output_file)
291+
with open(input_file_path, 'r', encoding='UTF-8') as input_file:
292+
with open(output_file_path, 'w', encoding='UTF-8') as output_file:
293+
for i, l in enumerate(input_file.readlines()):
294+
parser = choose_parser()
295+
#print(parser.__name__ == "pos_replace_parser")
296+
if i % 1000 == 0:
297+
log.debug('parsing line %d' % i)
298+
print(l.strip(), file=output_file)
299+
300+
for k in range(args.aug_times):
301+
cols = l.strip().split('\t')
302+
for j in col_nums:
303+
if parser.__name__ == "pos_replace_parser":
304+
cols[j - 1] = parser(cols[j - 1], pos_dict[j - 1])
305+
counter[parser.__name__] += 1
306+
else:
307+
cols[j - 1] = parser(cols[j - 1])
308+
counter[parser.__name__] += 1
309+
new_line = '\t'.join(cols)
310+
print(new_line, file=output_file)
312311

313312
elif six.PY2:
314313
with open(input_file_path) as input_file:

0 commit comments

Comments
 (0)