Augments text by transforming words with their embeddings.
| 116 | |
| 117 | |
| 118 | class EmbeddingAugmenter(Augmenter): |
| 119 | """Augments text by transforming words with their embeddings.""" |
| 120 | |
| 121 | def __init__(self, **kwargs): |
| 122 | from textattack.transformations import WordSwapEmbedding |
| 123 | |
| 124 | transformation = WordSwapEmbedding(max_candidates=50) |
| 125 | from textattack.constraints.semantics import WordEmbeddingDistance |
| 126 | |
| 127 | constraints = DEFAULT_CONSTRAINTS + [WordEmbeddingDistance(min_cos_sim=0.8)] |
| 128 | super().__init__(transformation, constraints=constraints, **kwargs) |
| 129 | |
| 130 | |
| 131 | class CharSwapAugmenter(Augmenter): |
no outgoing calls