updated loader.
Browse files- xscitldr_staging.py +5 -5
xscitldr_staging.py
CHANGED
@@ -123,7 +123,7 @@ class XSciTLDRStaging(datasets.GeneratorBasedBuilder):
|
|
123 |
name=datasets.Split.TRAIN,
|
124 |
# These kwargs will be passed to _generate_examples
|
125 |
gen_kwargs={
|
126 |
-
"
|
127 |
"split": "train",
|
128 |
},
|
129 |
),
|
@@ -131,7 +131,7 @@ class XSciTLDRStaging(datasets.GeneratorBasedBuilder):
|
|
131 |
name=datasets.Split.TEST,
|
132 |
# These kwargs will be passed to _generate_examples
|
133 |
gen_kwargs={
|
134 |
-
"
|
135 |
"split": "test"
|
136 |
},
|
137 |
),
|
@@ -139,17 +139,17 @@ class XSciTLDRStaging(datasets.GeneratorBasedBuilder):
|
|
139 |
name=datasets.Split.VALIDATION,
|
140 |
# These kwargs will be passed to _generate_examples
|
141 |
gen_kwargs={
|
142 |
-
"
|
143 |
"split": "dev",
|
144 |
},
|
145 |
),
|
146 |
]
|
147 |
|
148 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
149 |
-
def _generate_examples(self,
|
150 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
151 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
152 |
-
with open(
|
153 |
for key, row in enumerate(f):
|
154 |
data = json.loads(row)
|
155 |
yield key, {
|
|
|
123 |
name=datasets.Split.TRAIN,
|
124 |
# These kwargs will be passed to _generate_examples
|
125 |
gen_kwargs={
|
126 |
+
"filepath": data_path_train,
|
127 |
"split": "train",
|
128 |
},
|
129 |
),
|
|
|
131 |
name=datasets.Split.TEST,
|
132 |
# These kwargs will be passed to _generate_examples
|
133 |
gen_kwargs={
|
134 |
+
"filepath": data_path_test,
|
135 |
"split": "test"
|
136 |
},
|
137 |
),
|
|
|
139 |
name=datasets.Split.VALIDATION,
|
140 |
# These kwargs will be passed to _generate_examples
|
141 |
gen_kwargs={
|
142 |
+
"filepath": data_path_dev,
|
143 |
"split": "dev",
|
144 |
},
|
145 |
),
|
146 |
]
|
147 |
|
148 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
149 |
+
def _generate_examples(self, filepath, split):
|
150 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
151 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
152 |
+
with open(filepath, encoding="utf-8") as f:
|
153 |
for key, row in enumerate(f):
|
154 |
data = json.loads(row)
|
155 |
yield key, {
|