albertvillanova HF staff commited on
Commit
7276113
·
verified ·
1 Parent(s): b04c414

Delete loading script

Browse files
Files changed (1) hide show
  1. qangaroo.py +0 -126
qangaroo.py DELETED
@@ -1,126 +0,0 @@
1
- """TODO(qangaroo): Add a description here."""
2
-
3
-
4
- import json
5
- import os
6
-
7
- import datasets
8
-
9
-
10
- # TODO(qangaroo): BibTeX citation
11
-
12
- _CITATION = """
13
- """
14
-
15
- # TODO(quangaroo):
16
- _DESCRIPTION = """\
17
- We have created two new Reading Comprehension datasets focussing on multi-hop (alias multi-step) inference.
18
-
19
- Several pieces of information often jointly imply another fact. In multi-hop inference, a new fact is derived by combining facts via a chain of multiple steps.
20
-
21
- Our aim is to build Reading Comprehension methods that perform multi-hop inference on text, where individual facts are spread out across different documents.
22
-
23
- The two QAngaroo datasets provide a training and evaluation resource for such methods.
24
- """
25
-
26
- _MEDHOP_DESCRIPTION = """\
27
- With the same format as WikiHop, this dataset is based on research paper abstracts from PubMed, and the queries are about interactions between pairs of drugs.
28
- The correct answer has to be inferred by combining information from a chain of reactions of drugs and proteins.
29
- """
30
- _WIKIHOP_DESCRIPTION = """\
31
- With the same format as WikiHop, this dataset is based on research paper abstracts from PubMed, and the queries are about interactions between pairs of drugs.
32
- The correct answer has to be inferred by combining information from a chain of reactions of drugs and proteins.
33
- """
34
-
35
- _URL = "qangaroo_v1.1.zip"
36
-
37
-
38
- class QangarooConfig(datasets.BuilderConfig):
39
- def __init__(self, data_dir, **kwargs):
40
- """BuilderConfig for qangaroo dataset
41
-
42
- Args:
43
- data_dir: directory for the given dataset name
44
- **kwargs: keyword arguments forwarded to super.
45
-
46
- """
47
-
48
- super(QangarooConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
49
-
50
- self.data_dir = data_dir
51
-
52
-
53
- class Qangaroo(datasets.GeneratorBasedBuilder):
54
- """TODO(qangaroo): Short description of my dataset."""
55
-
56
- # TODO(qangaroo): Set up version.
57
- VERSION = datasets.Version("0.1.0")
58
- BUILDER_CONFIGS = [
59
- QangarooConfig(name="medhop", description=_MEDHOP_DESCRIPTION, data_dir="medhop"),
60
- QangarooConfig(name="masked_medhop", description=_MEDHOP_DESCRIPTION, data_dir="medhop"),
61
- QangarooConfig(name="wikihop", description=_WIKIHOP_DESCRIPTION, data_dir="wikihop"),
62
- QangarooConfig(name="masked_wikihop", description=_WIKIHOP_DESCRIPTION, data_dir="wikihop"),
63
- ]
64
-
65
- def _info(self):
66
- # TODO(qangaroo): Specifies the datasets.DatasetInfo object
67
- return datasets.DatasetInfo(
68
- # This is the description that will appear on the datasets page.
69
- description=_DESCRIPTION,
70
- # datasets.features.FeatureConnectors
71
- features=datasets.Features(
72
- {
73
- # These are the features of your dataset like images, labels ...
74
- "query": datasets.Value("string"),
75
- "supports": datasets.features.Sequence(datasets.Value("string")),
76
- "candidates": datasets.features.Sequence(datasets.Value("string")),
77
- "answer": datasets.Value("string"),
78
- "id": datasets.Value("string")
79
- # These are the features of your dataset like images, labels ...
80
- }
81
- ),
82
- # If there's a common (input, target) tuple from the features,
83
- # specify them here. They'll be used if as_supervised=True in
84
- # builder.as_dataset.
85
- supervised_keys=None,
86
- # Homepage of the dataset for documentation
87
- homepage="http://qangaroo.cs.ucl.ac.uk/index.html",
88
- citation=_CITATION,
89
- )
90
-
91
- def _split_generators(self, dl_manager):
92
- """Returns SplitGenerators."""
93
- # TODO(qangaroo): Downloads the data and defines the splits
94
- # dl_manager is a datasets.download.DownloadManager that can be used to
95
- # download and extract URLs
96
- dl_dir = dl_manager.download_and_extract(_URL)
97
- data_dir = os.path.join(dl_dir, "qangaroo_v1.1")
98
- train_file = "train.masked.json" if "masked" in self.config.name else "train.json"
99
- dev_file = "dev.masked.json" if "masked" in self.config.name else "dev.json"
100
- return [
101
- datasets.SplitGenerator(
102
- name=datasets.Split.TRAIN,
103
- # These kwargs will be passed to _generate_examples
104
- gen_kwargs={"filepath": os.path.join(data_dir, self.config.data_dir, train_file)},
105
- ),
106
- datasets.SplitGenerator(
107
- name=datasets.Split.VALIDATION,
108
- # These kwargs will be passed to _generate_examples
109
- gen_kwargs={"filepath": os.path.join(data_dir, self.config.data_dir, dev_file)},
110
- ),
111
- ]
112
-
113
- def _generate_examples(self, filepath):
114
- """Yields examples."""
115
- # TODO(quangaroo): Yields (key, example) tuples from the dataset
116
- with open(filepath, encoding="utf-8") as f:
117
- data = json.load(f)
118
- for example in data:
119
- id_ = example["id"]
120
- yield id_, {
121
- "id": example["id"],
122
- "query": example["query"],
123
- "supports": example["supports"],
124
- "candidates": example["candidates"],
125
- "answer": example["answer"],
126
- }