Skip to content

Commit

Permalink
Merge pull request #734 from eldorabdukhamidov/patch-1
Browse files Browse the repository at this point in the history
Fixed syntax and import issues in the example of Attack API
  • Loading branch information
jxmorris12 committed Aug 28, 2023
2 parents c3da2b4 + e43085c commit cab4e0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions textattack/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cab4e0f

Please sign in to comment.