(attack)
| 488 | |
| 489 | @staticmethod |
| 490 | def attack_interactive(attack): |
| 491 | print(attack, "\n") |
| 492 | |
| 493 | print("Running in interactive mode") |
| 494 | print("----------------------------") |
| 495 | |
| 496 | while True: |
| 497 | print('Enter a sentence to attack or "q" to quit:') |
| 498 | text = input() |
| 499 | |
| 500 | if text == "q": |
| 501 | break |
| 502 | |
| 503 | if not text: |
| 504 | continue |
| 505 | |
| 506 | print("Attacking...") |
| 507 | |
| 508 | example = textattack.shared.attacked_text.AttackedText(text) |
| 509 | output = attack.goal_function.get_output(example) |
| 510 | result = attack.attack(example, output) |
| 511 | print(result.__str__(color_method="ansi") + "\n") |
| 512 | |
| 513 | |
| 514 | # |
no test coverage detected