Adding a transforms class [check details]
Closed this issue · 5 comments
rajaswa commented
- To add a transforms class (similar to PyTorch transforms)
- Should be able to compose various transforms (ex: char perturbations) and apply them to a text sample
- An analogy can be drawn:
#Torchvision
transform = transforms.compose([rotate, crop, resize, grayscale])
transformed_image = transfrom.apply(image)
#AdvNLP
transform = transforms.compose([add, swap, delete, visually_similar])
transformed_text = transfrom.apply(text)
rajaswa commented
Where add, swap, delete etc are the object instances of their respective classes
This enhancement needs a lot of discussion before actually starting with the implementation. So plz do let us know if you have any ideas
abheesht17 commented
The user can input anything, like a word/sentence/document, right? So, for character perturbations, what we can do is:
- Make subclasses of the transforms class where we call the functions from perturbations.py. These act on one word alone. For example, classes like transforms.Add, transforms.Delete, etc.
- Now, since a text sample will contain multiple words, we can use functions from extractor.py to extract the important words' indices (I think the RandomWordExtractor class has been implemented) and apply the above mentioned transforms to those words only.
rajaswa commented
@abheesht17 That's exactly what we need to do. Are you willing to take this up?
abheesht17 commented
Yep, I'll do it.
rajaswa commented
Resolved in #69 by @abheesht17