lvwerra HF staff commited on
Commit
72fc92e
1 Parent(s): f2195c5

Update Space (evaluate main: c447fc8e)

Browse files
Files changed (2) hide show
  1. coval.py +9 -25
  2. requirements.txt +1 -1
coval.py CHANGED
@@ -12,8 +12,6 @@
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
  """ CoVal metric. """
15
- from dataclasses import dataclass
16
-
17
  import coval # From: git+https://github.com/ns-moosavi/coval.git noqa: F401
18
  import datasets
19
  from coval.conll import reader, util
@@ -271,29 +269,13 @@ def check_gold_parse_annotation(key_lines):
271
  return has_gold_parse
272
 
273
 
274
- @dataclass
275
- class CovalConfig(evaluate.info.Config):
276
-
277
- name: str = "default"
278
-
279
- keep_singletons: bool = True
280
- NP_only: bool = False
281
- min_span: bool = False
282
- remove_nested: bool = False
283
-
284
-
285
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
286
  class Coval(evaluate.Metric):
287
-
288
- CONFIG_CLASS = CovalConfig
289
- ALLOWED_CONFIG_NAMES = ["default"]
290
-
291
- def _info(self, config):
292
  return evaluate.MetricInfo(
293
  description=_DESCRIPTION,
294
  citation=_CITATION,
295
  inputs_description=_KWARGS_DESCRIPTION,
296
- config=config,
297
  features=datasets.Features(
298
  {
299
  "predictions": datasets.Sequence(datasets.Value("string")),
@@ -308,7 +290,9 @@ class Coval(evaluate.Metric):
308
  ],
309
  )
310
 
311
- def _compute(self, predictions, references):
 
 
312
  allmetrics = [
313
  ("mentions", evaluator.mentions),
314
  ("muc", evaluator.muc),
@@ -317,7 +301,7 @@ class Coval(evaluate.Metric):
317
  ("lea", evaluator.lea),
318
  ]
319
 
320
- if self.config.min_span:
321
  has_gold_parse = util.check_gold_parse_annotation(references)
322
  if not has_gold_parse:
323
  raise NotImplementedError("References should have gold parse annotation to use 'min_span'.")
@@ -328,10 +312,10 @@ class Coval(evaluate.Metric):
328
  key_lines=references,
329
  sys_lines=predictions,
330
  metrics=allmetrics,
331
- NP_only=self.config.NP_only,
332
- remove_nested=self.config.remove_nested,
333
- keep_singletons=self.config.keep_singletons,
334
- min_span=self.config.min_span,
335
  )
336
 
337
  return score
 
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
  """ CoVal metric. """
 
 
15
  import coval # From: git+https://github.com/ns-moosavi/coval.git noqa: F401
16
  import datasets
17
  from coval.conll import reader, util
 
269
  return has_gold_parse
270
 
271
 
 
 
 
 
 
 
 
 
 
 
 
272
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
273
  class Coval(evaluate.Metric):
274
+ def _info(self):
 
 
 
 
275
  return evaluate.MetricInfo(
276
  description=_DESCRIPTION,
277
  citation=_CITATION,
278
  inputs_description=_KWARGS_DESCRIPTION,
 
279
  features=datasets.Features(
280
  {
281
  "predictions": datasets.Sequence(datasets.Value("string")),
 
290
  ],
291
  )
292
 
293
+ def _compute(
294
+ self, predictions, references, keep_singletons=True, NP_only=False, min_span=False, remove_nested=False
295
+ ):
296
  allmetrics = [
297
  ("mentions", evaluator.mentions),
298
  ("muc", evaluator.muc),
 
301
  ("lea", evaluator.lea),
302
  ]
303
 
304
+ if min_span:
305
  has_gold_parse = util.check_gold_parse_annotation(references)
306
  if not has_gold_parse:
307
  raise NotImplementedError("References should have gold parse annotation to use 'min_span'.")
 
312
  key_lines=references,
313
  sys_lines=predictions,
314
  metrics=allmetrics,
315
+ NP_only=NP_only,
316
+ remove_nested=remove_nested,
317
+ keep_singletons=keep_singletons,
318
+ min_span=min_span,
319
  )
320
 
321
  return score
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- git+https://github.com/huggingface/evaluate@e4a2724377909fe2aeb4357e3971e5a569673b39
2
  git+https://github.com/ns-moosavi/coval.git
 
1
+ git+https://github.com/huggingface/evaluate@c447fc8eda9c62af501bfdc6988919571050d950
2
  git+https://github.com/ns-moosavi/coval.git