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

bug of naw.RandomWordAug(action='swap') #76

Closed
RenShuhuai-Andy opened this issue Jan 3, 2020 · 2 comments
Closed

bug of naw.RandomWordAug(action='swap') #76

RenShuhuai-Andy opened this issue Jan 3, 2020 · 2 comments

Comments

@RenShuhuai-Andy
Copy link

If the text has only one word, the function naw.RandomWordAug(action='swap') will change words in position 0 and position 1, then it will throw en error: IndexError: list index out of range. Maybe you can add a determine statement that if text has only one word, then return it directly.

@RenShuhuai-Andy
Copy link
Author

Exact error location: nlpaug/augmenter/word/random.py/ line 45 swap_position = self._get_swap_position(i, len(original_tokens) - 1). The swap_position will be 1 is there is only one token in text.

@RenShuhuai-Andy
Copy link
Author

Similar problem happens when use naw.RandomWordAug(action=delete) while a text has only one token. In this scenario, the token will be deleted and the text will become nan.

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

1 participant