fix
Browse files
ecqa.py
CHANGED
@@ -123,8 +123,8 @@ class ecqa(evaluate.Metric):
|
|
123 |
return white_space_fix(text)
|
124 |
|
125 |
def __compute_f1(self, prediction: str, reference: str)-> tuple[float, float, float]:
|
126 |
-
predicted_tokens = prediction.split()
|
127 |
-
referenced_tokens = reference.split()
|
128 |
|
129 |
predictied_chars = []
|
130 |
for token in predicted_tokens:
|
@@ -141,12 +141,14 @@ class ecqa(evaluate.Metric):
|
|
141 |
f1 = (2 * precision * recall) / (precision + recall)
|
142 |
|
143 |
return f1, recall, precision
|
|
|
144 |
def _compute(self, predictions: list[str], references: list[str]):
|
145 |
"""Returns the scores"""
|
146 |
# TODO: Compute the different scores of the module
|
147 |
assert isinstance(predictions, list)
|
148 |
assert isinstance(references, list)
|
149 |
assert len(predictions) == len(references)
|
|
|
150 |
f1_acc = precision_acc = recall_acc = total = 0
|
151 |
for prediction, reference in zip(predictions, references):
|
152 |
total += 1
|
@@ -166,6 +168,7 @@ class ecqa(evaluate.Metric):
|
|
166 |
recall_acc
|
167 |
]
|
168 |
]
|
|
|
169 |
return {
|
170 |
"f1": f1,
|
171 |
"precision": precision,
|
|
|
123 |
return white_space_fix(text)
|
124 |
|
125 |
def __compute_f1(self, prediction: str, reference: str)-> tuple[float, float, float]:
|
126 |
+
predicted_tokens = self.__normalize(prediction).split()
|
127 |
+
referenced_tokens = self.__normalize(reference).split()
|
128 |
|
129 |
predictied_chars = []
|
130 |
for token in predicted_tokens:
|
|
|
141 |
f1 = (2 * precision * recall) / (precision + recall)
|
142 |
|
143 |
return f1, recall, precision
|
144 |
+
|
145 |
def _compute(self, predictions: list[str], references: list[str]):
|
146 |
"""Returns the scores"""
|
147 |
# TODO: Compute the different scores of the module
|
148 |
assert isinstance(predictions, list)
|
149 |
assert isinstance(references, list)
|
150 |
assert len(predictions) == len(references)
|
151 |
+
|
152 |
f1_acc = precision_acc = recall_acc = total = 0
|
153 |
for prediction, reference in zip(predictions, references):
|
154 |
total += 1
|
|
|
168 |
recall_acc
|
169 |
]
|
170 |
]
|
171 |
+
|
172 |
return {
|
173 |
"f1": f1,
|
174 |
"precision": precision,
|