Spaces:
Running
Running
Update Space (evaluate main: c447fc8e)
Browse files- cer.py +3 -17
- requirements.txt +1 -1
cer.py
CHANGED
@@ -13,7 +13,6 @@
|
|
13 |
# limitations under the License.
|
14 |
""" Character Error Ratio (CER) metric. """
|
15 |
|
16 |
-
from dataclasses import dataclass
|
17 |
from typing import List
|
18 |
|
19 |
import datasets
|
@@ -116,26 +115,13 @@ Examples:
|
|
116 |
"""
|
117 |
|
118 |
|
119 |
-
@dataclass
|
120 |
-
class CERConfig(evaluate.info.Config):
|
121 |
-
|
122 |
-
name: str = "default"
|
123 |
-
|
124 |
-
concatenate_texts: bool = False
|
125 |
-
|
126 |
-
|
127 |
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
128 |
class CER(evaluate.Metric):
|
129 |
-
|
130 |
-
CONFIG_CLASS = CERConfig
|
131 |
-
ALLOWED_CONFIG_NAMES = ["default"]
|
132 |
-
|
133 |
-
def _info(self, config):
|
134 |
return evaluate.MetricInfo(
|
135 |
description=_DESCRIPTION,
|
136 |
citation=_CITATION,
|
137 |
inputs_description=_KWARGS_DESCRIPTION,
|
138 |
-
config=config,
|
139 |
features=datasets.Features(
|
140 |
{
|
141 |
"predictions": datasets.Value("string", id="sequence"),
|
@@ -149,8 +135,8 @@ class CER(evaluate.Metric):
|
|
149 |
],
|
150 |
)
|
151 |
|
152 |
-
def _compute(self, predictions, references):
|
153 |
-
if
|
154 |
return jiwer.compute_measures(
|
155 |
references,
|
156 |
predictions,
|
|
|
13 |
# limitations under the License.
|
14 |
""" Character Error Ratio (CER) metric. """
|
15 |
|
|
|
16 |
from typing import List
|
17 |
|
18 |
import datasets
|
|
|
115 |
"""
|
116 |
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
119 |
class CER(evaluate.Metric):
|
120 |
+
def _info(self):
|
|
|
|
|
|
|
|
|
121 |
return evaluate.MetricInfo(
|
122 |
description=_DESCRIPTION,
|
123 |
citation=_CITATION,
|
124 |
inputs_description=_KWARGS_DESCRIPTION,
|
|
|
125 |
features=datasets.Features(
|
126 |
{
|
127 |
"predictions": datasets.Value("string", id="sequence"),
|
|
|
135 |
],
|
136 |
)
|
137 |
|
138 |
+
def _compute(self, predictions, references, concatenate_texts=False):
|
139 |
+
if concatenate_texts:
|
140 |
return jiwer.compute_measures(
|
141 |
references,
|
142 |
predictions,
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
git+https://github.com/huggingface/evaluate@
|
2 |
jiwer
|
|
|
1 |
+
git+https://github.com/huggingface/evaluate@c447fc8eda9c62af501bfdc6988919571050d950
|
2 |
jiwer
|