Attack Result API Reference
AttackResult
- class textattack.attack_results.AttackResult(original_result, perturbed_result)[source]
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.