lvwerra HF staff commited on
Commit
50a8f17
1 Parent(s): b2f5f46

Update Space (evaluate main: c447fc8e)

Browse files
Files changed (2) hide show
  1. chrf.py +13 -29
  2. requirements.txt +1 -1
chrf.py CHANGED
@@ -12,8 +12,6 @@
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
  """ Chrf(++) metric as available in sacrebleu. """
15
- from dataclasses import dataclass
16
-
17
  import datasets
18
  import sacrebleu as scb
19
  from packaging import version
@@ -125,25 +123,9 @@ Examples:
125
  """
126
 
127
 
128
- @dataclass
129
- class ChrFConfig(evaluate.info.Config):
130
-
131
- name: str = "default"
132
-
133
- char_order: int = CHRF.CHAR_ORDER
134
- word_order: int = CHRF.WORD_ORDER
135
- beta: int = CHRF.BETA
136
- lowercase: bool = False
137
- whitespace: bool = False
138
- eps_smoothing: bool = False
139
-
140
-
141
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
142
  class ChrF(evaluate.Metric):
143
- CONFIG_CLASS = ChrFConfig
144
- ALLOWED_CONFIG_NAMES = ["default"]
145
-
146
- def _info(self, config):
147
  if version.parse(scb.__version__) < version.parse("1.4.12"):
148
  raise ImportWarning(
149
  "To use `sacrebleu`, the module `sacrebleu>=1.4.12` is required, and the current version of `sacrebleu` doesn't match this condition.\n"
@@ -154,7 +136,6 @@ class ChrF(evaluate.Metric):
154
  citation=_CITATION,
155
  homepage="https://github.com/mjpost/sacreBLEU#chrf--chrf",
156
  inputs_description=_KWARGS_DESCRIPTION,
157
- config=config,
158
  features=[
159
  datasets.Features(
160
  {
@@ -175,7 +156,17 @@ class ChrF(evaluate.Metric):
175
  ],
176
  )
177
 
178
- def _compute(self, predictions, references):
 
 
 
 
 
 
 
 
 
 
179
  # if only one reference is provided make sure we still use list of lists
180
  if isinstance(references[0], str):
181
  references = [[ref] for ref in references]
@@ -186,14 +177,7 @@ class ChrF(evaluate.Metric):
186
  )
187
  transformed_references = [[refs[i] for refs in references] for i in range(references_per_prediction)]
188
 
189
- sb_chrf = CHRF(
190
- self.config.char_order,
191
- self.config.word_order,
192
- self.config.beta,
193
- self.config.lowercase,
194
- self.config.whitespace,
195
- self.config.eps_smoothing,
196
- )
197
  output = sb_chrf.corpus_score(predictions, transformed_references)
198
 
199
  return {
 
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
  """ Chrf(++) metric as available in sacrebleu. """
 
 
15
  import datasets
16
  import sacrebleu as scb
17
  from packaging import version
 
123
  """
124
 
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
127
  class ChrF(evaluate.Metric):
128
+ def _info(self):
 
 
 
129
  if version.parse(scb.__version__) < version.parse("1.4.12"):
130
  raise ImportWarning(
131
  "To use `sacrebleu`, the module `sacrebleu>=1.4.12` is required, and the current version of `sacrebleu` doesn't match this condition.\n"
 
136
  citation=_CITATION,
137
  homepage="https://github.com/mjpost/sacreBLEU#chrf--chrf",
138
  inputs_description=_KWARGS_DESCRIPTION,
 
139
  features=[
140
  datasets.Features(
141
  {
 
156
  ],
157
  )
158
 
159
+ def _compute(
160
+ self,
161
+ predictions,
162
+ references,
163
+ char_order: int = CHRF.CHAR_ORDER,
164
+ word_order: int = CHRF.WORD_ORDER,
165
+ beta: int = CHRF.BETA,
166
+ lowercase: bool = False,
167
+ whitespace: bool = False,
168
+ eps_smoothing: bool = False,
169
+ ):
170
  # if only one reference is provided make sure we still use list of lists
171
  if isinstance(references[0], str):
172
  references = [[ref] for ref in references]
 
177
  )
178
  transformed_references = [[refs[i] for refs in references] for i in range(references_per_prediction)]
179
 
180
+ sb_chrf = CHRF(char_order, word_order, beta, lowercase, whitespace, eps_smoothing)
 
 
 
 
 
 
 
181
  output = sb_chrf.corpus_score(predictions, transformed_references)
182
 
183
  return {
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- git+https://github.com/huggingface/evaluate@e4a2724377909fe2aeb4357e3971e5a569673b39
2
  sacrebleu
 
1
+ git+https://github.com/huggingface/evaluate@c447fc8eda9c62af501bfdc6988919571050d950
2
  sacrebleu