allow for multiple paths in one split
Browse files
NLVR2.py
CHANGED
|
@@ -83,15 +83,15 @@ class NLVR2Dataset(datasets.GeneratorBasedBuilder):
|
|
| 83 |
return [
|
| 84 |
datasets.SplitGenerator(
|
| 85 |
name=datasets.Split.TRAIN,
|
| 86 |
-
gen_kwargs={"
|
| 87 |
),
|
| 88 |
datasets.SplitGenerator(
|
| 89 |
name=datasets.Split.VALIDATION,
|
| 90 |
-
gen_kwargs={"
|
| 91 |
),
|
| 92 |
datasets.SplitGenerator(
|
| 93 |
name=datasets.Split.TEST,
|
| 94 |
-
gen_kwargs={"
|
| 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,
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
| 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
|