Lexi commited on
Commit
35f49f4
1 Parent(s): 22b5382

Update NQ_squad_format.py

Browse files
Files changed (1) hide show
  1. NQ_squad_format.py +9 -9
NQ_squad_format.py CHANGED
@@ -47,11 +47,11 @@ articles, where the answer to every question is a segment of text, or span, \
47
  from the corresponding reading passage, or the question might be unanswerable.
48
  """
49
 
50
- _URL = "https://rajpurkar.github.io/SQuAD-explorer/dataset/"
51
- _URLS = {
52
- "train": _URL + "train-v1.1.json",
53
- "dev": _URL + "dev-v1.1.json",
54
- }
55
 
56
 
57
  class SquadConfig(datasets.BuilderConfig):
@@ -107,8 +107,8 @@ class Squad(datasets.GeneratorBasedBuilder):
107
  downloaded_files = dl_manager.download_and_extract(_URLS)
108
 
109
  return [
110
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
111
- datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
112
  ]
113
 
114
  def _generate_examples(self, filepath):
@@ -117,8 +117,8 @@ class Squad(datasets.GeneratorBasedBuilder):
117
  key = 0
118
  with open(filepath, encoding="utf-8") as f:
119
  data = json.load(f)
120
- print("example data: ", data['data'][0])
121
- for line in data['data']:
122
  yield key, {
123
  "context": line['context'],
124
  "question": line["question"],
 
47
  from the corresponding reading passage, or the question might be unanswerable.
48
  """
49
 
50
+ #_URL = "https://rajpurkar.github.io/SQuAD-explorer/dataset/"
51
+ #_URLS = {
52
+ # "train": _URL + "train-v1.1.json",
53
+ # "dev": _URL + "dev-v1.1.json",
54
+ #}
55
 
56
 
57
  class SquadConfig(datasets.BuilderConfig):
 
107
  downloaded_files = dl_manager.download_and_extract(_URLS)
108
 
109
  return [
110
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": "train.json"]}),
111
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": "dev.json"]}),
112
  ]
113
 
114
  def _generate_examples(self, filepath):
 
117
  key = 0
118
  with open(filepath, encoding="utf-8") as f:
119
  data = json.load(f)
120
+ print("example data: ", data[0])
121
+ for line in data:
122
  yield key, {
123
  "context": line['context'],
124
  "question": line["question"],