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

rename recipes (tests pass)

This commit is contained in:
Jack Morris
2020-05-06 10:26:01 -04:00
parent 394d95c23e
commit 6e9dd74654
9 changed files with 21 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
from .alzantot_2018_genetic_algorithm import Alzantot2018GeneticAlgorithm from .alzantot_2018 import Alzantot2018
from .alzantot_2018_genetic_algorithm_adjusted import Alzantot2018GeneticAlgorithmAdjusted from .alzantot_2018_adjusted import Alzantot2018Adjusted
from .cheng_2018_seq2sick_blackbox import Cheng2018Seq2SickBlackBox from .deepwordbug_gao_2018 import DeepWordBugGao2018
from .ebrahimi_2017_hotflip import Ebrahimi2017HotFlip from .hotflip_ebrahimi_2017 import HotFlipEbrahimi2017
from .jin_2019_textfooler import Jin2019TextFooler from .seq2sick_cheng_2018_blackbox import Seq2SickCheng2018BlackBox
from .jin_2019_textfooler_adjusted import Jin2019TextFoolerAdjusted from .textfooler_jin_2019 import TextFoolerJin2019
from .gao_2018_deepwordbug import Gao2018DeepWordBug from .textfooler_jin_2019_adjusted import TextFoolerJin2019Adjusted

View File

@@ -16,7 +16,7 @@ from textattack.constraints.semantics.language_models import GoogleLanguageModel
from textattack.transformations.black_box import WordSwapEmbedding from textattack.transformations.black_box import WordSwapEmbedding
from textattack.goal_functions import UntargetedClassification from textattack.goal_functions import UntargetedClassification
def Alzantot2018GeneticAlgorithm(model): def Alzantot2018(model):
# #
# Swap words with their embedding nearest-neighbors. # Swap words with their embedding nearest-neighbors.
# #

View File

@@ -16,7 +16,7 @@ from textattack.constraints.syntax import PartOfSpeech, LanguageTool
from textattack.transformations.black_box import WordSwapEmbedding from textattack.transformations.black_box import WordSwapEmbedding
from textattack.goal_functions import UntargetedClassification from textattack.goal_functions import UntargetedClassification
def Alzantot2018GeneticAlgorithmAdjusted(model, SE_thresh=0.98, sentence_encoder='bert'): def Alzantot2018Adjusted(model, SE_thresh=0.98, sentence_encoder='bert'):
# #
# Swap words with their embedding nearest-neighbors. # Swap words with their embedding nearest-neighbors.
# #

View File

@@ -16,7 +16,7 @@ from textattack.transformations.black_box import \
WordSwapRandomCharacterDeletion, WordSwapRandomCharacterInsertion, \ WordSwapRandomCharacterDeletion, WordSwapRandomCharacterInsertion, \
WordSwapRandomCharacterSubstitution, WordSwapNeighboringCharacterSwap WordSwapRandomCharacterSubstitution, WordSwapNeighboringCharacterSwap
def Gao2018DeepWordBug(model, use_all_transformations=True): def DeepWordBugGao2018(model, use_all_transformations=True):
# #
# Swap characters out from words. Choose the best of four potential transformations. # Swap characters out from words. Choose the best of four potential transformations.
# #

View File

@@ -18,7 +18,7 @@ from textattack.constraints.syntax import PartOfSpeech
from textattack.transformations.white_box import GradientBasedWordSwap from textattack.transformations.white_box import GradientBasedWordSwap
from textattack.goal_functions import UntargetedClassification from textattack.goal_functions import UntargetedClassification
def Ebrahimi2017HotFlip(model): def HotFlipEbrahimi2017(model):
# #
# "HotFlip ... uses the gradient with respect to a one-hot input # "HotFlip ... uses the gradient with respect to a one-hot input
# representation to efficiently estimate which individual change has the # representation to efficiently estimate which individual change has the

View File

@@ -17,7 +17,7 @@ from textattack.constraints.overlap import LevenshteinEditDistance
from textattack.goal_functions import NonOverlappingOutput from textattack.goal_functions import NonOverlappingOutput
from textattack.transformations.black_box import WordSwapEmbedding from textattack.transformations.black_box import WordSwapEmbedding
def Cheng2018Seq2SickBlackBox(model, goal_function='non_overlapping'): def Seq2SickCheng2018BlackBox(model, goal_function='non_overlapping'):
# #
# Goal is non-overlapping output. # Goal is non-overlapping output.
# #

View File

@@ -15,7 +15,7 @@ from textattack.constraints.syntax import PartOfSpeech
from textattack.transformations.black_box import WordSwapEmbedding from textattack.transformations.black_box import WordSwapEmbedding
from textattack.goal_functions import UntargetedClassification from textattack.goal_functions import UntargetedClassification
def Jin2019TextFooler(model): def TextFoolerJin2019(model):
# #
# Swap words with their embedding nearest-neighbors. # Swap words with their embedding nearest-neighbors.
# #

View File

@@ -15,7 +15,7 @@ from textattack.constraints.syntax import PartOfSpeech, LanguageTool
from textattack.transformations.black_box import WordSwapEmbedding from textattack.transformations.black_box import WordSwapEmbedding
from textattack.goal_functions import UntargetedClassification from textattack.goal_functions import UntargetedClassification
def Jin2019TextFoolerAdjusted(model, SE_thresh=0.98, sentence_encoder='bert'): def TextFoolerJin2019Adjusted(model, SE_thresh=0.98, sentence_encoder='bert'):
# #
# Swap words with their embedding nearest-neighbors. # Swap words with their embedding nearest-neighbors.
# #

View File

@@ -8,13 +8,13 @@ import time
import torch import torch
RECIPE_NAMES = { RECIPE_NAMES = {
'alzantot': 'textattack.attack_recipes.Alzantot2018GeneticAlgorithm', 'alzantot': 'textattack.attack_recipes.Alzantot2018',
'alz-adjusted': 'textattack.attack_recipes.Alzantot2018GeneticAlgorithmAdjusted', 'alz-adjusted': 'textattack.attack_recipes.Alzantot2018Adjusted',
'deepwordbug': 'textattack.attack_recipes.Gao2018DeepWordBug', 'deepwordbug': 'textattack.attack_recipes.DeepWordBugGao2018',
'hotflip': 'textattack.attack_recipes.Ebrahimi2017HotFlip', 'hotflip': 'textattack.attack_recipes.HotFlipEbrahimi2017',
'seq2sick': 'textattack.attack_recipes.Cheng2018Seq2SickBlackBox', 'seq2sick': 'textattack.attack_recipes.Seq2SickCheng2018BlackBox',
'textfooler': 'textattack.attack_recipes.Jin2019TextFooler', 'textfooler': 'textattack.attack_recipes.TextFoolerJin2019',
'tf-adjusted': 'textattack.attack_recipes.Jin2019TextFoolerAdjusted', 'tf-adjusted': 'textattack.attack_recipes.TextFoolerJin2019Adjusted',
} }
MODEL_CLASS_NAMES = { MODEL_CLASS_NAMES = {