MCPcopy
hub / github.com/QData/TextAttack / attack_interactive

Method attack_interactive

textattack/attacker.py:490–511  ·  view source on GitHub ↗
(attack)

Source from the content-addressed store, hash-verified

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#

Callers 1

runMethod · 0.80

Calls 3

get_outputMethod · 0.80
attackMethod · 0.80
__str__Method · 0.80

Tested by

no test coverage detected