Skip to content

Commit

Permalink
Merge pull request #797 from bterrific2008/augmenter_eda_fix
Browse files Browse the repository at this point in the history
Fix bug where EDA augmentation recipe would not accept default Augmentation arguments
  • Loading branch information
jxmorris12 authored Jul 25, 2024
2 parents ad88963 + 4df80a0 commit 5fbb076
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 5fbb076

Please sign in to comment.