clefourrier HF Staff commited on
Commit
0742b9b
·
1 Parent(s): 2efe5be

Update sacrebleu_manual.py

Browse files
Files changed (1) hide show
  1. sacrebleu_manual.py +11 -7
sacrebleu_manual.py CHANGED
@@ -2,9 +2,13 @@
2
  NOTE: This file implements translation tasks using datasets from WMT conferences,
3
  provided by sacrebleu. Traditionally they are evaluated with BLEU scores. TER
4
  and CHRF are other options.
 
 
 
 
 
5
  Homepage: https://github.com/mjpost/sacrebleu/blob/master/sacrebleu/dataset.py
6
  """
7
- import os
8
  import pycountry
9
  from sacrebleu import sacrebleu
10
  import datasets
@@ -24,12 +28,12 @@ _CITATION = """
24
  }
25
  """
26
 
27
- sacrebleu_datasets = sacrebleu.DATASETS
28
 
 
 
29
 
30
- class Sacrebleu(datasets.GeneratorBasedBuilder):
31
  BUILDER_CONFIGS = [
32
- datasets.BuilderConfig(name=f"{name.replace('/', '__')}__{langpair}", version=datasets.Version("1.0.0"), description="")
33
  for name in sacrebleu.get_available_testsets()
34
  for langpair in sacrebleu.get_langpairs_for_testset(name)
35
  ]
@@ -52,12 +56,12 @@ class Sacrebleu(datasets.GeneratorBasedBuilder):
52
  return [
53
  datasets.SplitGenerator(
54
  name=datasets.Split.TEST,
55
- gen_kwargs={path: f"{self.config.name}.jsonl"},
56
  )
57
  ]
58
 
59
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
60
- def _generate_examples(self, path):
61
- with open(os.path.join(path.split("__")), encoding="utf-8") as f:
62
  for key, row in enumerate(f):
63
  yield key, json.loads(row)
 
2
  NOTE: This file implements translation tasks using datasets from WMT conferences,
3
  provided by sacrebleu. Traditionally they are evaluated with BLEU scores. TER
4
  and CHRF are other options.
5
+
6
+ We defer citations and descriptions of the many translations tasks used
7
+ here to the SacreBLEU repo from which we've obtained the datasets:
8
+ https://github.com/mjpost/sacrebleu/blob/master/sacrebleu/dataset.py
9
+
10
  Homepage: https://github.com/mjpost/sacrebleu/blob/master/sacrebleu/dataset.py
11
  """
 
12
  import pycountry
13
  from sacrebleu import sacrebleu
14
  import datasets
 
28
  }
29
  """
30
 
 
31
 
32
+ class SacrebleuManual(datasets.GeneratorBasedBuilder):
33
+ VERSION = datasets.Version("1.0.0")
34
 
 
35
  BUILDER_CONFIGS = [
36
+ datasets.BuilderConfig(name=f"{name.replace('/', ' ')} {langpair}", version=datasets.Version("1.0.0"), description="")
37
  for name in sacrebleu.get_available_testsets()
38
  for langpair in sacrebleu.get_langpairs_for_testset(name)
39
  ]
 
56
  return [
57
  datasets.SplitGenerator(
58
  name=datasets.Split.TEST,
59
+ gen_kwargs={},
60
  )
61
  ]
62
 
63
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
64
+ def _generate_examples(self):
65
+ with open(f"{os.path.join(self.config.name.split(' '))}.jsonl", encoding="utf-8") as f:
66
  for key, row in enumerate(f):
67
  yield key, json.loads(row)