Skip to content

Commit

Permalink
reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
jstzwj committed Jul 7, 2024
1 parent be325c8 commit e59bd3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions textattack/metrics/attack_metrics/words_perturbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def calculate(self, results):
self.all_metrics["avg_word_perturbed"] = self.avg_number_word_perturbed_num()
self.all_metrics["avg_word_perturbed_perc"] = self.avg_perturbation_perc()
self.all_metrics["max_words_changed"] = self.max_words_changed
self.all_metrics["num_words_changed_until_success"] = (
self.num_words_changed_until_success
)
self.all_metrics[
"num_words_changed_until_success"
] = self.num_words_changed_until_success

return self.all_metrics

Expand Down
6 changes: 3 additions & 3 deletions textattack/search_methods/particle_swarm_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def _turn(self, source_text, target_text, prob, original_text):
& indices_to_replace
)
if "last_transformation" in source_text.attacked_text.attack_attrs:
new_text.attack_attrs["last_transformation"] = (
source_text.attacked_text.attack_attrs["last_transformation"]
)
new_text.attack_attrs[
"last_transformation"
] = source_text.attacked_text.attack_attrs["last_transformation"]

if not self.post_turn_check or (new_text.words == source_text.words):
break
Expand Down
5 changes: 1 addition & 4 deletions textattack/shared/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
r"^textattack.models.helpers.word_cnn_for_classification.*",
r"^transformers.modeling_\w*\.\w*ForSequenceClassification$",
],
(
NonOverlappingOutput,
MinimizeBleu,
): [
(NonOverlappingOutput, MinimizeBleu,): [
r"^textattack.models.helpers.t5_for_text_to_text.*",
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@


class BackTranscription(SentenceTransformation):
"""A type of sentence level transformation that takes in a text input, converts it into
synthesized speech using ASR, and transcribes it back to text using TTS.
"""A type of sentence level transformation that takes in a text input,
converts it into synthesized speech using ASR, and transcribes it back to
text using TTS.
tts_model: text-to-speech model from huggingface
asr_model: automatic speech recognition model from huggingface
Expand Down

0 comments on commit e59bd3b

Please sign in to comment.