SaylorTwift HF Staff commited on
Commit
ab1fcce
·
verified ·
1 Parent(s): eb67b0d

Delete loading script

Browse files
Files changed (1) hide show
  1. sacrebleu_manual.py +0 -72
sacrebleu_manual.py DELETED
@@ -1,72 +0,0 @@
1
- """
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
- We defer citations and descriptions of the many translations tasks used
6
- here to the SacreBLEU repo from which we've obtained the datasets:
7
- https://github.com/mjpost/sacrebleu/blob/master/sacrebleu/dataset.py
8
- Homepage: https://github.com/mjpost/sacrebleu/blob/master/sacrebleu/dataset.py
9
- """
10
- from sacrebleu import sacrebleu
11
- import datasets
12
- import os
13
- import json
14
-
15
-
16
- _CITATION = """
17
- @inproceedings{post-2018-call,
18
- title = "A Call for Clarity in Reporting {BLEU} Scores",
19
- author = "Post, Matt",
20
- booktitle = "Proceedings of the Third Conference on Machine Translation: Research Papers",
21
- month = oct,
22
- year = "2018",
23
- address = "Belgium, Brussels",
24
- publisher = "Association for Computational Linguistics",
25
- url = "https://www.aclweb.org/anthology/W18-6319",
26
- pages = "186--191",
27
- }
28
- """
29
-
30
-
31
- class SacrebleuManual(datasets.GeneratorBasedBuilder):
32
- VERSION = datasets.Version("1.0.0")
33
-
34
- names = [name for name in list(sacrebleu.get_available_testsets()) if name not in ["wmt23", "wmt24"] and "wmt21" not in name]
35
- print(names)
36
-
37
- BUILDER_CONFIGS = [
38
- datasets.BuilderConfig(name=f"{name.replace('/', '_')}_{langpair}", version=datasets.Version("1.0.0"), description="")
39
- for name in names
40
- for langpair in sacrebleu.get_langpairs_for_testset(name)
41
- ]
42
-
43
- def _info(self):
44
- features = datasets.Features(
45
- {
46
- "translation": datasets.Value("string"),
47
- }
48
- )
49
- return datasets.DatasetInfo(
50
- description=f"Sacrebleu\n{self.config.description}",
51
- features=features,
52
- homepage="",
53
- license="",
54
- citation=_CITATION,
55
- )
56
-
57
- def _split_generators(self, dl_manager):
58
- downloaded_files = dl_manager.download(f"{os.path.join(*self.config.name.split('_'))}.jsonl")
59
- print(downloaded_files)
60
-
61
- return [
62
- datasets.SplitGenerator(
63
- name=datasets.Split.TEST,
64
- gen_kwargs={"path": downloaded_files},
65
- )
66
- ]
67
-
68
- # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
69
- def _generate_examples(self, path):
70
- with open(path, encoding="utf-8") as f:
71
- for key, row in enumerate(f):
72
- yield key, json.loads(row)