textflint.generation_layer.transformation.NLI.add_sent

Adding the Meaningless sentences to the hypothesis

class textflint.generation_layer.transformation.NLI.add_sent.AddSent[source]

Bases: textflint.generation_layer.transformation.transformation.Transformation

Adding the Meaningless sentences to the hypothesis and remain both premise and label. Users can use their own meaningless sentences by change the text in transform method

exmaple: {

hypothesis: I hate this book. premise: This book is my favorite. today is Monday. y: contradiction

}

transform(sample, n=1, text=' And we have to say that the sun is not moon, the moon is not sun.', **kwargs)[source]

Transform data sample to a list of Sample.

Parameters
  • sample (~NLISample) – Data sample for augmentation

  • n (int) – Default is 1. MAX number of unique augmented output

  • **kwargs

Returns

Augmented data

class textflint.generation_layer.transformation.NLI.add_sent.Transformation(**kwargs)[source]

Bases: abc.ABC

An 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

classmethod sample_num(x, num)[source]

Get ‘num’ samples from x.

Parameters
  • x (list) – list to sample

  • num (int) – sample number

Returns

max ‘num’ unique samples.