File size: 735 Bytes
4a1df2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Metric Class
========================

"""

from abc import ABC, abstractmethod


class Metric(ABC):
    """A metric for evaluating Adversarial Attack candidates."""

    @abstractmethod
    def __init__(self, **kwargs):
        """Creates pre-built :class:`~textattack.Metric` that correspond to
        evaluation metrics for adversarial examples."""
        raise NotImplementedError()

    @abstractmethod
    def calculate(self, results):
        """Abstract function for computing any values which are to be calculated as a whole during initialization
        Args:
            results (``AttackResult`` objects):
                    Attack results for each instance in dataset
        """

        raise NotImplementedError