Spaces:
Running
Running
Update Space (evaluate main: e4a27243)
Browse files- cer.py +17 -3
- requirements.txt +1 -1
cer.py
CHANGED
@@ -13,6 +13,7 @@
|
|
13 |
# limitations under the License.
|
14 |
""" Character Error Ratio (CER) metric. """
|
15 |
|
|
|
16 |
from typing import List
|
17 |
|
18 |
import datasets
|
@@ -115,13 +116,26 @@ Examples:
|
|
115 |
"""
|
116 |
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
119 |
class CER(evaluate.Metric):
|
120 |
-
|
|
|
|
|
|
|
|
|
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,8 +149,8 @@ class CER(evaluate.Metric):
|
|
135 |
],
|
136 |
)
|
137 |
|
138 |
-
def _compute(self, predictions, references
|
139 |
-
if concatenate_texts:
|
140 |
return jiwer.compute_measures(
|
141 |
references,
|
142 |
predictions,
|
|
|
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 |
"""
|
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 |
],
|
150 |
)
|
151 |
|
152 |
+
def _compute(self, predictions, references):
|
153 |
+
if self.config.concatenate_texts:
|
154 |
return jiwer.compute_measures(
|
155 |
references,
|
156 |
predictions,
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
git+https://github.com/huggingface/evaluate@
|
2 |
jiwer
|
|
|
1 |
+
git+https://github.com/huggingface/evaluate@e4a2724377909fe2aeb4357e3971e5a569673b39
|
2 |
jiwer
|