mirror of
https://github.com/QData/TextAttack.git
synced 2021-10-13 00:05:06 +03:00
Conflicts: textattack/attacks/attack.py textattack/constraints/constraint.py textattack/constraints/semantics/universal_sentence_encoder.py textattack/perturbations/perturbation.py textattack/transformations/word_swap.py textattack/transformations/word_swap_counterfit.py
20 lines
570 B
Python
20 lines
570 B
Python
""" Abstract classes represent constraints on text adversarial examples.
|
|
"""
|
|
|
|
|
|
class Constraint:
|
|
"""
|
|
An abstract class that represents constraints on adversial text examples.
|
|
A constraint evaluates if (x,x_adv) meets a certain constraint.
|
|
|
|
"""
|
|
|
|
def call_many(self, x, x_adv_list, original_text=None):
|
|
""" Filters x_adv_list to x_adv where C(x,x_adv) is true.
|
|
"""
|
|
raise NotImplementedError()
|
|
|
|
def __call__(self, x, x_adv):
|
|
""" Returns True if C(x,x_adv) is true. """
|
|
raise NotImplementedError()
|