textflint.generation_layer.transformation.SM.swap_num¶
Transforms an input by replacing its number word¶
-
class
textflint.generation_layer.transformation.SM.swap_num.SwapNum[source]¶ Bases:
textflint.generation_layer.transformation.transformation.TransformationTransforms an input by replacing its number word
Exmaple:
{sentence1: Every people has two hands. sentence2: There are five hands with all of us. label: 0
}
-
class
textflint.generation_layer.transformation.SM.swap_num.Transformation(**kwargs)[source]¶ Bases:
abc.ABCAn abstract class for transforming a sequence of text to produce a list of potential adversarial example.
-
processor= <textflint.common.preprocess.en_processor.EnProcessor object>¶
-
transform(sample, n=1, field='x', **kwargs)[source]¶ Transform data sample to a list of Sample.
- Parameters
sample (Sample) – Data sample for augmentation.
n (int) – Max number of unique augmented output, default is 5.
field (str|list) – Indicate which fields to apply transformations.
**kwargs (dict) –
other auxiliary params.
- Returns
list of Sample
-