forked from GEM-benchmark/NL-Augmenter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Operation.py
40 lines (33 loc) Β· 965 Bytes
/
Operation.py
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
29
30
31
32
33
34
35
36
37
38
39
40
from typing import Tuple, List
"""Generic operation class. """
class Operation(object):
languages = None
tasks = None
seed = 0
heavy = False
max_outputs = 1
def __init__(self, seed=0, verbose=False, max_outputs=1):
self.seed = seed
self.verbose = verbose
self.max_outputs = max_outputs
if self.verbose:
print(f"Loading Operation {self.name()}")
@classmethod
def compare(self, raw: object, pt: List[object]) -> Tuple[int, int]:
successful_pt = 0
failed_pt = 0
for pt_example in pt:
if pt_example == raw:
failed_pt += 1
else:
successful_pt += 1
return successful_pt, failed_pt
@classmethod
def is_heavy(cls):
return cls.heavy
@classmethod
def domain(cls):
return cls.tasks, cls.languages
@classmethod
def name(cls):
return cls.__name__