1
0
mirror of https://github.com/QData/TextAttack.git synced 2021-10-13 00:05:06 +03:00

add warning [tests pass]

This commit is contained in:
Jack Morris
2020-07-29 10:18:21 -04:00
parent d82dd4e127
commit d66d374a19

View File

@@ -165,9 +165,15 @@ class Attack:
original_text: The original ``AttackedText`` from which the attack started.
"""
# Remove any occurences of current_text in transformed_texts
original_num_texts = len(transformed_texts)
transformed_texts = [
t for t in transformed_texts if t.text != current_text.text
]
if len(transformed_texts) < original_num_texts:
# If this happened, warn the user
utils.logger.warn(
"Warning: transformation returned text with no changes. Skipping."
)
# Populate cache with transformed_texts
uncached_texts = []
for transformed_text in transformed_texts: