Leyo commited on
Commit
1c1c2be
·
1 Parent(s): 5a7a94d

allow for multiple paths in one split

Browse files
Files changed (1) hide show
  1. NLVR2.py +17 -15
NLVR2.py CHANGED
@@ -83,15 +83,15 @@ class NLVR2Dataset(datasets.GeneratorBasedBuilder):
83
  return [
84
  datasets.SplitGenerator(
85
  name=datasets.Split.TRAIN,
86
- gen_kwargs={"files_path": files_path[self.config.name]["train"]},
87
  ),
88
  datasets.SplitGenerator(
89
  name=datasets.Split.VALIDATION,
90
- gen_kwargs={"files_path": files_path[self.config.name]["validation"]},
91
  ),
92
  datasets.SplitGenerator(
93
  name=datasets.Split.TEST,
94
- gen_kwargs={"files_path": files_path[self.config.name]["test1"]},
95
  ),
96
  # datasets.SplitGenerator(
97
  # name=datasets.Split.TEST2,
@@ -99,15 +99,17 @@ class NLVR2Dataset(datasets.GeneratorBasedBuilder):
99
  # ),
100
  ]
101
 
102
- def _generate_examples(self, files_path):
103
- json_file = [json.loads(line) for line in open(files_path).readlines()]
104
-
105
- for i, ex in enumerate(json_file):
106
- record = {
107
- "identifier": ex["identifier"],
108
- "sentence": ex["sentence"],
109
- "left_image": str(ex["left_url"]),
110
- "right_image": str(ex["right_url"]),
111
- "label": ex["label"],
112
- }
113
- yield i, record
 
 
 
83
  return [
84
  datasets.SplitGenerator(
85
  name=datasets.Split.TRAIN,
86
+ gen_kwargs={"files_paths": [files_path[self.config.name]["train"]]},
87
  ),
88
  datasets.SplitGenerator(
89
  name=datasets.Split.VALIDATION,
90
+ gen_kwargs={"files_paths": [files_path[self.config.name]["validation"]]},
91
  ),
92
  datasets.SplitGenerator(
93
  name=datasets.Split.TEST,
94
+ gen_kwargs={"files_paths": [files_path[self.config.name]["test1"], files_path[self.config.name]["test2"]]},
95
  ),
96
  # datasets.SplitGenerator(
97
  # name=datasets.Split.TEST2,
 
99
  # ),
100
  ]
101
 
102
+ def _generate_examples(self, files_paths):
103
+ idx = 0
104
+ for path in files_paths:
105
+ for line in open(path).readlines():
106
+ ex = json.loads(line)
107
+ record = {
108
+ "identifier": ex["identifier"],
109
+ "sentence": ex["sentence"],
110
+ "left_image": str(ex["left_url"]),
111
+ "right_image": str(ex["right_url"]),
112
+ "label": ex["label"],
113
+ }
114
+ idx += 1
115
+ yield idx, record