makcedward/nlpaug

Bug on 1.1.11

ririya opened this issue · 0 comments

ririya commented

Running into a bug with a sequential flow. The same is not happening on 1.1.10

def char_aug(data, ocr_error_dict, p_replace=0.1, p_insert=0.1, p_delete=0.1,
             replace_char_p=0.05, insert_char_p=0.05, delete_char_p=0.05,
             lowercase=False):

    ocr_aug = nac.OcrAug(
                aug_char_min=1,
                aug_char_p=replace_char_p,
                dict_of_path=ocr_error_dict,
            )
    insert_aug = nac.RandomCharAug(
                action="insert",
                aug_char_min=1,
                aug_char_p=insert_char_p,
            )
    delete_aug = nac.RandomCharAug(
                action="delete",
                aug_char_min=1,
                aug_char_p=delete_char_p,
                stopwords_regex="^.$",  # Don't do any replacements on single characters
            )

    ocr_sometimes = naf.Sometimes(ocr_aug, aug_p=p_replace)
    insert_sometimes = naf.Sometimes(insert_aug, aug_p=p_insert)
    delete_sometimes = naf.Sometimes(delete_aug, aug_p=p_delete)
    sequential_flow = naf.Sequential([ocr_sometimes, insert_sometimes, delete_sometimes])

    if lowercase:
        data = data.lower()

    augmented = sequential_flow.augment(data)[0]
Traceback (most recent call last):
  File "/mnt/c/Users/Rafael/My Drive/codes/pam-ml-2.0/util/augmentation.py", line 206, in <module>
    augmented = char_aug("abc def ghi jkl mno pqr stu wxy z 01234567890 [] ", ocr_error_dict,
  File "/mnt/c/Users/Rafael/My Drive/codes/pam-ml-2.0/util/augmentation.py", line 174, in char_aug
    augmented = sequential_flow.augment(data)[0]
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/flow/pipeline.py", line 58, in augment
    augmented_results = [self._augment(data) for _ in range(n)]
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/flow/pipeline.py", line 58, in <listcomp>
    augmented_results = [self._augment(data) for _ in range(n)]
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/flow/pipeline.py", line 101, in _augment
    augmented_data = aug.augment(augmented_data, n=n, num_thread=num_thread)
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/flow/pipeline.py", line 58, in augment
    augmented_results = [self._augment(data) for _ in range(n)]
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/flow/pipeline.py", line 58, in <listcomp>
    augmented_results = [self._augment(data) for _ in range(n)]
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/flow/pipeline.py", line 101, in _augment
    augmented_data = aug.augment(augmented_data, n=n, num_thread=num_thread)
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/base_augmenter.py", line 75, in augment
    clean_data = self.clean(data)
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/augmenter/char/char_augmenter.py", line 40, in clean
    return [d.strip() for d in data]
  File "/home/rafael/anaconda3/envs/llm_env/lib/python3.8/site-packages/nlpaug/augmenter/char/char_augmenter.py", line 40, in <listcomp>
    return [d.strip() for d in data]
AttributeError: 'list' object has no attribute 'strip'