SaylorTwift HF Staff commited on
Commit
5f41c2c
·
verified ·
1 Parent(s): fb14468

Delete loading script

Browse files
Files changed (1) hide show
  1. mutual_harness.py +0 -136
mutual_harness.py DELETED
@@ -1,136 +0,0 @@
1
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """MuTual dataset."""
15
-
16
-
17
- import json
18
- import os
19
- from pathlib import Path
20
-
21
- import datasets
22
-
23
-
24
- _CITATION = """\
25
- @inproceedings{mutual,
26
- title = "MuTual: A Dataset for Multi-Turn Dialogue Reasoning",
27
- author = "Cui, Leyang and Wu, Yu and Liu, Shujie and Zhang, Yue and Zhou, Ming" ,
28
- booktitle = "Proceedings of the 58th Conference of the Association for Computational Linguistics",
29
- year = "2020",
30
- publisher = "Association for Computational Linguistics",
31
- }
32
- """
33
-
34
- _DESCRIPTION = """\
35
- MuTual is a retrieval-based dataset for multi-turn dialogue reasoning, which is
36
- modified from Chinese high school English listening comprehension test data.
37
- """
38
-
39
- _HOMEPAGE = "https://github.com/Nealcly/MuTual"
40
-
41
- # TODO: Add the licence for the dataset here if you can find it
42
- _LICENSE = ""
43
-
44
- _URLS = "https://github.com/Nealcly/MuTual/archive/master.zip"
45
-
46
-
47
- class Mutual(datasets.GeneratorBasedBuilder):
48
- """MuTual: A Dataset for Multi-Turn Dialogue Reasoning"""
49
-
50
- VERSION = datasets.Version("0.0.1")
51
-
52
- BUILDER_CONFIGS = [
53
- datasets.BuilderConfig(
54
- name="mutual", version=VERSION, description="The MuTual dataset."
55
- ),
56
- datasets.BuilderConfig(
57
- name="mutual_plus",
58
- version=VERSION,
59
- description="MuTualPlus is a more difficult MuTual that replaces positive responses with a safe responses.",
60
- ),
61
- ]
62
-
63
- def _info(self):
64
- features = datasets.Features(
65
- {
66
- "answers": datasets.Value("string"),
67
- "options": datasets.features.Sequence(datasets.Value("string")),
68
- "article": datasets.Value("string"),
69
- "id": datasets.Value("string"),
70
- }
71
- )
72
- return datasets.DatasetInfo(
73
- description=f"{_DESCRIPTION}\n{self.config.description}",
74
- features=features,
75
- homepage=_HOMEPAGE,
76
- license=_LICENSE,
77
- citation=_CITATION,
78
- )
79
-
80
- def _split_generators(self, dl_manager):
81
- urls = _URLS
82
- data_dir = dl_manager.download_and_extract(urls)
83
- return [
84
- datasets.SplitGenerator(
85
- name=datasets.Split.TRAIN,
86
- # These kwargs will be passed to _generate_examples
87
- gen_kwargs={
88
- "basepath": os.path.join(
89
- data_dir, "MuTual-master", "data", self.config.name, "train"
90
- ),
91
- "split": "train",
92
- },
93
- ),
94
- datasets.SplitGenerator(
95
- name=datasets.Split.TEST,
96
- # These kwargs will be passed to _generate_examples
97
- gen_kwargs={
98
- "basepath": os.path.join(
99
- data_dir, "MuTual-master", "data", self.config.name, "test"
100
- ),
101
- "split": "test",
102
- },
103
- ),
104
- datasets.SplitGenerator(
105
- name=datasets.Split.VALIDATION,
106
- # These kwargs will be passed to _generate_examples
107
- gen_kwargs={
108
- "basepath": os.path.join(
109
- data_dir, "MuTual-master", "data", self.config.name, "dev"
110
- ),
111
- "split": "dev",
112
- },
113
- ),
114
- ]
115
-
116
- # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
117
- def _generate_examples(self, basepath, split):
118
- # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
119
- # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
120
- key = 0
121
- for file in sorted(Path(basepath).iterdir()):
122
- if file.suffix != ".txt":
123
- continue
124
- with open(file, "r", encoding="utf-8") as f:
125
- data_str = f.read()
126
- # Ignore the occasional empty file.
127
- if not data_str:
128
- continue
129
- data = json.loads(data_str)
130
- yield key, {
131
- "answers": data["answers"],
132
- "options": data["options"],
133
- "article": data["article"],
134
- "id": data["id"],
135
- }
136
- key += 1