File size: 873 Bytes
4943752 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
"""
FailedAttackResult Class
===========================
"""
from textattack.shared import utils
from .attack_result import AttackResult
class FailedAttackResult(AttackResult):
"""The result of a failed attack."""
def __init__(self, original_result, perturbed_result=None):
perturbed_result = perturbed_result or original_result
super().__init__(original_result, perturbed_result)
def str_lines(self, color_method=None):
lines = (
self.goal_function_result_str(color_method),
self.original_text(color_method),
)
return tuple(map(str, lines))
def goal_function_result_str(self, color_method=None):
failed_str = utils.color_text("[FAILED]", "red", color_method)
return (
self.original_result.get_colored_output(color_method) + " --> " + failed_str
)
|