textattack.attack_results package
TextAttack attack_results Package
AttackResult Class
- class textattack.attack_results.attack_result.AttackResult(original_result, perturbed_result)[source]
Bases:
ABC
Result of an Attack run on a single (output, text_input) pair.
- Parameters:
original_result (
GoalFunctionResult
) – Result of the goal function applied to the original textperturbed_result (
GoalFunctionResult
) – Result of the goal function applied to the perturbed text. May or may not have been successful.
- diff_color(color_method=None)[source]
Highlights the difference between two texts using color.
Has to account for deletions and insertions from original text to perturbed. Relies on the index map stored in
self.original_result.attacked_text.attack_attrs["original_index_map"]
.
- goal_function_result_str(color_method=None)[source]
Returns a string illustrating the results of the goal function.
- original_text(color_method=None)[source]
Returns the text portion of self.original_result.
Helper method.
FailedAttackResult Class
- class textattack.attack_results.failed_attack_result.FailedAttackResult(original_result, perturbed_result=None)[source]
Bases:
AttackResult
The result of a failed attack.
MaximizedAttackResult Class
- class textattack.attack_results.maximized_attack_result.MaximizedAttackResult(original_result, perturbed_result)[source]
Bases:
AttackResult
The result of a successful attack.
SkippedAttackResult Class
- class textattack.attack_results.skipped_attack_result.SkippedAttackResult(original_result)[source]
Bases:
AttackResult
The result of a skipped attack.
SuccessfulAttackResult Class
- class textattack.attack_results.successful_attack_result.SuccessfulAttackResult(original_result, perturbed_result)[source]
Bases:
AttackResult
The result of a successful attack.