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:
@@ -1,7 +1,7 @@
|
||||
from .alzantot_2018_genetic_algorithm import Alzantot2018GeneticAlgorithm
|
||||
from .alzantot_2018_genetic_algorithm_adjusted import Alzantot2018GeneticAlgorithmAdjusted
|
||||
from .cheng_2018_seq2sick_blackbox import Cheng2018Seq2SickBlackBox
|
||||
from .ebrahimi_2017_hotflip import Ebrahimi2017HotFlip
|
||||
from .jin_2019_textfooler import Jin2019TextFooler
|
||||
from .jin_2019_textfooler_adjusted import Jin2019TextFoolerAdjusted
|
||||
from .gao_2018_deepwordbug import Gao2018DeepWordBug
|
||||
from .alzantot_2018 import Alzantot2018
|
||||
from .alzantot_2018_adjusted import Alzantot2018Adjusted
|
||||
from .deepwordbug_gao_2018 import DeepWordBugGao2018
|
||||
from .hotflip_ebrahimi_2017 import HotFlipEbrahimi2017
|
||||
from .seq2sick_cheng_2018_blackbox import Seq2SickCheng2018BlackBox
|
||||
from .textfooler_jin_2019 import TextFoolerJin2019
|
||||
from .textfooler_jin_2019_adjusted import TextFoolerJin2019Adjusted
|
||||
@@ -16,7 +16,7 @@ from textattack.constraints.semantics.language_models import GoogleLanguageModel
|
||||
from textattack.transformations.black_box import WordSwapEmbedding
|
||||
from textattack.goal_functions import UntargetedClassification
|
||||
|
||||
def Alzantot2018GeneticAlgorithm(model):
|
||||
def Alzantot2018(model):
|
||||
#
|
||||
# Swap words with their embedding nearest-neighbors.
|
||||
#
|
||||
@@ -16,7 +16,7 @@ from textattack.constraints.syntax import PartOfSpeech, LanguageTool
|
||||
from textattack.transformations.black_box import WordSwapEmbedding
|
||||
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.
|
||||
#
|
||||
@@ -16,7 +16,7 @@ from textattack.transformations.black_box import \
|
||||
WordSwapRandomCharacterDeletion, WordSwapRandomCharacterInsertion, \
|
||||
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.
|
||||
#
|
||||
@@ -18,7 +18,7 @@ from textattack.constraints.syntax import PartOfSpeech
|
||||
from textattack.transformations.white_box import GradientBasedWordSwap
|
||||
from textattack.goal_functions import UntargetedClassification
|
||||
|
||||
def Ebrahimi2017HotFlip(model):
|
||||
def HotFlipEbrahimi2017(model):
|
||||
#
|
||||
# "HotFlip ... uses the gradient with respect to a one-hot input
|
||||
# representation to efficiently estimate which individual change has the
|
||||
@@ -17,7 +17,7 @@ from textattack.constraints.overlap import LevenshteinEditDistance
|
||||
from textattack.goal_functions import NonOverlappingOutput
|
||||
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.
|
||||
#
|
||||
@@ -15,7 +15,7 @@ from textattack.constraints.syntax import PartOfSpeech
|
||||
from textattack.transformations.black_box import WordSwapEmbedding
|
||||
from textattack.goal_functions import UntargetedClassification
|
||||
|
||||
def Jin2019TextFooler(model):
|
||||
def TextFoolerJin2019(model):
|
||||
#
|
||||
# Swap words with their embedding nearest-neighbors.
|
||||
#
|
||||
@@ -15,7 +15,7 @@ from textattack.constraints.syntax import PartOfSpeech, LanguageTool
|
||||
from textattack.transformations.black_box import WordSwapEmbedding
|
||||
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.
|
||||
#
|
||||
@@ -8,13 +8,13 @@ import time
|
||||
import torch
|
||||
|
||||
RECIPE_NAMES = {
|
||||
'alzantot': 'textattack.attack_recipes.Alzantot2018GeneticAlgorithm',
|
||||
'alz-adjusted': 'textattack.attack_recipes.Alzantot2018GeneticAlgorithmAdjusted',
|
||||
'deepwordbug': 'textattack.attack_recipes.Gao2018DeepWordBug',
|
||||
'hotflip': 'textattack.attack_recipes.Ebrahimi2017HotFlip',
|
||||
'seq2sick': 'textattack.attack_recipes.Cheng2018Seq2SickBlackBox',
|
||||
'textfooler': 'textattack.attack_recipes.Jin2019TextFooler',
|
||||
'tf-adjusted': 'textattack.attack_recipes.Jin2019TextFoolerAdjusted',
|
||||
'alzantot': 'textattack.attack_recipes.Alzantot2018',
|
||||
'alz-adjusted': 'textattack.attack_recipes.Alzantot2018Adjusted',
|
||||
'deepwordbug': 'textattack.attack_recipes.DeepWordBugGao2018',
|
||||
'hotflip': 'textattack.attack_recipes.HotFlipEbrahimi2017',
|
||||
'seq2sick': 'textattack.attack_recipes.Seq2SickCheng2018BlackBox',
|
||||
'textfooler': 'textattack.attack_recipes.TextFoolerJin2019',
|
||||
'tf-adjusted': 'textattack.attack_recipes.TextFoolerJin2019Adjusted',
|
||||
}
|
||||
|
||||
MODEL_CLASS_NAMES = {
|
||||
|
||||
Reference in New Issue
Block a user