Datasets:

ArXiv:
Elron commited on
Commit
ba31342
1 Parent(s): d8d4369

Upload metric.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. metric.py +11 -7
metric.py CHANGED
@@ -5,6 +5,7 @@ import datasets
5
  import evaluate
6
  from datasets import Features, Sequence, Value
7
 
 
8
  from .artifact import __file__ as _
9
  from .blocks import __file__ as _
10
  from .card import __file__ as _
@@ -12,6 +13,7 @@ from .catalog import __file__ as _
12
  from .collections import __file__ as _
13
  from .common import __file__ as _
14
  from .dataclass import __file__ as _
 
15
  from .file_utils import __file__ as _
16
  from .fusion import __file__ as _
17
  from .generator_utils import __file__ as _
@@ -37,6 +39,7 @@ from .operators import (
37
  )
38
  from .operators import __file__ as _
39
  from .processors import __file__ as _
 
40
  from .recipe import __file__ as _
41
  from .register import __file__ as _
42
  from .register import register_all_artifacts
@@ -115,17 +118,18 @@ UNITXT_METRIC_SCHEMA = Features({"predictions": Value("string"), "references": d
115
 
116
 
117
  def _compute(predictions: List[str], references: Iterable, flatten: bool = False, split_name: str = "all"):
118
- recipe = MetricRecipe()
119
 
120
- multi_stream = recipe(predictions=predictions, references=references, split_name=split_name)
121
 
122
- if flatten:
123
- operator = FlattenInstances()
124
- multi_stream = operator(multi_stream)
125
 
126
- stream = multi_stream[split_name]
 
 
127
 
128
- return list(stream)
129
 
130
  # TODO: currently we have two classes with this name. metric.Metric and matrics.Metric...
131
  # @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
 
5
  import evaluate
6
  from datasets import Features, Sequence, Value
7
 
8
+ from ._version import __file__ as _
9
  from .artifact import __file__ as _
10
  from .blocks import __file__ as _
11
  from .card import __file__ as _
 
13
  from .collections import __file__ as _
14
  from .common import __file__ as _
15
  from .dataclass import __file__ as _
16
+ from .dict_utils import __file__ as _
17
  from .file_utils import __file__ as _
18
  from .fusion import __file__ as _
19
  from .generator_utils import __file__ as _
 
39
  )
40
  from .operators import __file__ as _
41
  from .processors import __file__ as _
42
+ from .random_utils import __file__ as _
43
  from .recipe import __file__ as _
44
  from .register import __file__ as _
45
  from .register import register_all_artifacts
 
118
 
119
 
120
  def _compute(predictions: List[str], references: Iterable, flatten: bool = False, split_name: str = "all"):
121
+ recipe = MetricRecipe()
122
 
123
+ multi_stream = recipe(predictions=predictions, references=references, split_name=split_name)
124
 
125
+ if flatten:
126
+ operator = FlattenInstances()
127
+ multi_stream = operator(multi_stream)
128
 
129
+ stream = multi_stream[split_name]
130
+
131
+ return list(stream)
132
 
 
133
 
134
  # TODO: currently we have two classes with this name. metric.Metric and matrics.Metric...
135
  # @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)