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

Fix bug where EDA augmentation recipe would not accept default Augmentation arguments #797

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions textattack/augmentation/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EasyDataAugmenter(Augmenter):
https://arxiv.org/abs/1901.11196
"""

def __init__(self, pct_words_to_swap=0.1, transformations_per_example=4):
def __init__(self, pct_words_to_swap=0.1, transformations_per_example=4, **kwargs):
assert 0.0 <= pct_words_to_swap <= 1.0, "pct_words_to_swap must be in [0., 1.]"
assert (
transformations_per_example > 0
Expand All @@ -49,17 +49,22 @@ def __init__(self, pct_words_to_swap=0.1, transformations_per_example=4):
self.synonym_replacement = WordNetAugmenter(
pct_words_to_swap=pct_words_to_swap,
transformations_per_example=n_aug_each,
**kwargs,
)
self.random_deletion = DeletionAugmenter(
pct_words_to_swap=pct_words_to_swap,
transformations_per_example=n_aug_each,
**kwargs,
)
self.random_swap = SwapAugmenter(
pct_words_to_swap=pct_words_to_swap,
transformations_per_example=n_aug_each,
**kwargs,
)
self.random_insertion = SynonymInsertionAugmenter(
pct_words_to_swap=pct_words_to_swap, transformations_per_example=n_aug_each
pct_words_to_swap=pct_words_to_swap,
transformations_per_example=n_aug_each,
**kwargs,
)

def augment(self, text):
Expand Down
Loading