makcedward/nlpaug

Keyboard Augmenter error with special characters

apolanco115 opened this issue · 0 comments

When using the Keyboard augmenter with special characters the following error is raised:

TypeError: argument of type 'NoneType' is not iterable

stack trace:


TypeError                                 Traceback (most recent call last)
<ipython-input-204-cc5b7c60cd49> in <module>
----> 1 aug.augment('#')

~/anaconda3/lib/python3.7/site-packages/nlpaug/base_augmenter.py in augment(self, data, n, num_thread)
     78                 # TODO: support multiprocessing for GPU
     79                 # https://discuss.pytorch.org/t/using-cuda-multiprocessing-with-single-gpu/7300
---> 80                 augmented_results = [action_fx(clean_data) for _ in range(n)]
     81             else:
     82                 augmented_results = self._parallel_augment(action_fx, clean_data, n=n, num_thread=num_thread)

~/anaconda3/lib/python3.7/site-packages/nlpaug/base_augmenter.py in <listcomp>(.0)
     78                 # TODO: support multiprocessing for GPU
     79                 # https://discuss.pytorch.org/t/using-cuda-multiprocessing-with-single-gpu/7300
---> 80                 augmented_results = [action_fx(clean_data) for _ in range(n)]
     81             else:
     82                 augmented_results = self._parallel_augment(action_fx, clean_data, n=n, num_thread=num_thread)

~/anaconda3/lib/python3.7/site-packages/nlpaug/augmenter/char/keyboard.py in substitute(self, data)
     75 
     76         for token_i, token in enumerate(tokens):
---> 77             if token_i not in aug_word_idxes:
     78                 results.append(token)
     79                 continue

TypeError: argument of type 'NoneType' is not iterable