From e43085c17b456ff49caa376726b4d386bf839685 Mon Sep 17 00:00:00 2001 From: Eldor Abdukhamidov Date: Mon, 15 May 2023 09:00:03 +0900 Subject: [PATCH] Update attack.py Fixed syntax and import issues in the example of Attack API --- textattack/attack.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/textattack/attack.py b/textattack/attack.py index dcc4ef7be..47537d1b0 100644 --- a/textattack/attack.py +++ b/textattack/attack.py @@ -57,18 +57,20 @@ class Attack: >>> # Construct our four components for `Attack` >>> from textattack.constraints.pre_transformation import RepeatModification, StopwordModification >>> from textattack.constraints.semantics import WordEmbeddingDistance + >>> from textattack.transformations import WordSwapEmbedding + >>> from textattack.search_methods import GreedyWordSwapWIR >>> goal_function = textattack.goal_functions.UntargetedClassification(model_wrapper) >>> constraints = [ ... RepeatModification(), - ... StopwordModification() + ... StopwordModification(), ... WordEmbeddingDistance(min_cos_sim=0.9) ... ] >>> transformation = WordSwapEmbedding(max_candidates=50) >>> search_method = GreedyWordSwapWIR(wir_method="delete") >>> # Construct the actual attack - >>> attack = Attack(goal_function, constraints, transformation, search_method) + >>> attack = textattack.Attack(goal_function, constraints, transformation, search_method) >>> input_text = "I really enjoyed the new movie that came out last month." >>> label = 1 #Positive