Datasets:

Modalities:
Text
Languages:
English
ArXiv:
Libraries:
Datasets
License:
system HF staff commited on
Commit
7114a9c
1 Parent(s): 5d20f54

Update files from the datasets library (from 1.16.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.16.0

Files changed (1) hide show
  1. qasper.py +13 -12
qasper.py CHANGED
@@ -18,7 +18,6 @@
18
 
19
 
20
  import json
21
- import os
22
 
23
  import datasets
24
 
@@ -39,8 +38,8 @@ A dataset containing 1585 papers with 5049 information-seeking questions asked b
39
  """
40
 
41
  _HOMEPAGE = "https://allenai.org/data/qasper"
42
- _DOWNLOAD_URLS = {"data": "https://qasper-dataset.s3-us-west-2.amazonaws.com/qasper-train-dev-v0.1.tgz"}
43
- data_files = {"train": "qasper-train-v0.1.json", "dev": "qasper-dev-v0.1.json"}
44
 
45
  _VERSION = "0.1.0"
46
 
@@ -107,24 +106,26 @@ class Qasper(datasets.GeneratorBasedBuilder):
107
  )
108
 
109
  def _split_generators(self, dl_manager):
110
- downloaded_files = dl_manager.download_and_extract(_DOWNLOAD_URLS)
111
 
112
  return [
113
  datasets.SplitGenerator(
114
  name=datasets.Split.TRAIN,
115
- gen_kwargs={"filepath": os.path.join(downloaded_files["data"], data_files["train"])},
116
  ),
117
  datasets.SplitGenerator(
118
  name=datasets.Split.VALIDATION,
119
- gen_kwargs={"filepath": os.path.join(downloaded_files["data"], data_files["dev"])},
120
  ),
121
  ]
122
 
123
- def _generate_examples(self, filepath):
124
  """This function returns the examples in the raw (text) form."""
125
  logger.info("generating examples from = %s", filepath)
126
- with open(filepath, encoding="utf-8") as f:
127
- qasper = json.load(f)
128
- for id_ in qasper:
129
- qasper[id_]["id"] = id_
130
- yield id_, qasper[id_]
 
 
 
18
 
19
 
20
  import json
 
21
 
22
  import datasets
23
 
 
38
  """
39
 
40
  _HOMEPAGE = "https://allenai.org/data/qasper"
41
+ _URL = "https://qasper-dataset.s3-us-west-2.amazonaws.com/qasper-train-dev-v0.1.tgz"
42
+ _DATA_FILES = {"train": "qasper-train-v0.1.json", "dev": "qasper-dev-v0.1.json"}
43
 
44
  _VERSION = "0.1.0"
45
 
 
106
  )
107
 
108
  def _split_generators(self, dl_manager):
109
+ archive = dl_manager.download(_URL)
110
 
111
  return [
112
  datasets.SplitGenerator(
113
  name=datasets.Split.TRAIN,
114
+ gen_kwargs={"filepath": _DATA_FILES["train"], "files": dl_manager.iter_archive(archive)},
115
  ),
116
  datasets.SplitGenerator(
117
  name=datasets.Split.VALIDATION,
118
+ gen_kwargs={"filepath": _DATA_FILES["dev"], "files": dl_manager.iter_archive(archive)},
119
  ),
120
  ]
121
 
122
+ def _generate_examples(self, filepath, files):
123
  """This function returns the examples in the raw (text) form."""
124
  logger.info("generating examples from = %s", filepath)
125
+ for path, f in files:
126
+ if path == filepath:
127
+ qasper = json.loads(f.read().decode("utf-8"))
128
+ for id_ in qasper:
129
+ qasper[id_]["id"] = id_
130
+ yield id_, qasper[id_]
131
+ break