Skip to content

Commit 2fe06d7

Browse files
committed
Fixing argument parser and adding validation
1 parent 9d32ae9 commit 2fe06d7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

code/augment.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,27 @@
3030

3131
#how much to replace each word by synonyms
3232
alpha_sr = 0.1#default
33-
if args.alpha_sr:
33+
if args.alpha_sr is not None:
3434
alpha_sr = args.alpha_sr
3535

3636
#how much to insert new words that are synonyms
3737
alpha_ri = 0.1#default
38-
if args.alpha_ri:
38+
if args.alpha_ri is not None:
3939
alpha_ri = args.alpha_ri
4040

4141
#how much to swap words
4242
alpha_rs = 0.1#default
43-
if args.alpha_rs:
43+
if args.alpha_rs is not None:
4444
alpha_rs = args.alpha_rs
4545

4646
#how much to delete words
4747
alpha_rd = 0.1#default
48-
if args.alpha_rd:
48+
if args.alpha_rd is not None:
4949
alpha_rd = args.alpha_rd
5050

51+
if alpha_sr == alpha_ri == alpha_rs == alpha_rd == 0:
52+
ap.error('At least one alpha should be greater than zero')
53+
5154
#generate more data with standard augmentation
5255
def gen_eda(train_orig, output_file, alpha_sr, alpha_ri, alpha_rs, alpha_rd, num_aug=9):
5356

0 commit comments

Comments
 (0)