Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty range for randrange() #22

Closed
drunkinlove opened this issue Mar 11, 2020 · 2 comments
Closed

empty range for randrange() #22

drunkinlove opened this issue Mar 11, 2020 · 2 comments

Comments

@drunkinlove
Copy link

Hello! Thank you for sharing your code.

I got this error on one of my datasets, is this a known problem? I've checked the text file and there are no empty (zero-length or whitespace-only) lines.

Traceback (most recent call last):
  File "code/augment.py", line 55, in <module>
    gen_eda(args.input, output, alpha=alpha, num_aug=num_aug)
  File "code/augment.py", line 44, in gen_eda
    aug_sentences = eda(sentence, alpha_sr=alpha, alpha_ri=alpha, alpha_rs=alpha, p_rd=alpha, num_aug=num_aug)
  File "/home/user/Desktop/eda_nlp/code/eda.py", line 193, in eda
    a_words = random_insertion(words, n_ri)
  File "/home/user/Desktop/eda_nlp/code/eda.py", line 153, in random_insertion
    add_word(new_words)
  File "/home/user/Desktop/eda_nlp/code/eda.py", line 160, in add_word
    random_word = new_words[random.randint(0, len(new_words)-1)]
  File "/home/stc/miniconda3/lib/python3.7/random.py", line 222, in randint
    return self.randrange(a, b+1)
  File "/home/stc/miniconda3/lib/python3.7/random.py", line 200, in randrange
    raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
@jasonwei20
Copy link
Owner

I'm not aware of this issue, can you show which the input data example that causes throws this error?

@drunkinlove
Copy link
Author

I debugged a little and the sentences that cause errors are very specific:

['189659', '0.0', '?']
['104101', '0.0', '?']
['208485', '0.0', '?']
['134403', '0.0', '?']
['13016', '0.0', '?']
['290090', '0.0', 'रिक्त स्थान भरो :-एक _____औरत _____पर बैठकर _____ गीत गा रही थी |उस _____ से दूर दूर तक _____ही दिखाई देती थी |इन पाँच खाली जगह पर एक ही शब्द आएगा']
['254161', '0.0', '?']
['169290', '0.0', '111']
['217458', '0.0', '3 9 6 15 45 30 75?']
['96725', '0.0', '?']
['182615', '0.0', '5+3+2=151012 9+2+4=183662 8+6+3=482466 5+4+5=202504 7+2+5=?']
['3306', '0.0', '.']
['20794', '0.0', '?']
['273065', '0.0', '?']
['190570', '0.0', '‘']
['301583', '0.0', '…..']
['342159', '0.0', '5+3+2=151012 9+2+4=183662 8+6+3=482466 5+4+5=202504 7+2+5=?']

(Third elements are sentences)
I'll just skip them, I suppose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants