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 on 1.1.11 #340

Open
ririya opened this issue Aug 28, 2023 · 0 comments
Open

Bug on 1.1.11 #340

ririya opened this issue Aug 28, 2023 · 0 comments

Comments

@ririya
Copy link

ririya commented Aug 28, 2023

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'

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