Update soybean_dataset.py
Browse files- soybean_dataset.py +1 -37
soybean_dataset.py
CHANGED
@@ -171,40 +171,4 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
171 |
|
172 |
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
#### origin
|
177 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
178 |
-
urls_to_download = self._URLS
|
179 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
180 |
-
|
181 |
-
return [
|
182 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
183 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
184 |
-
]
|
185 |
-
|
186 |
-
def _generate_examples(self, filepath):
|
187 |
-
"""This function returns the examples in the raw (text) form."""
|
188 |
-
logging.info("generating examples from = %s", filepath)
|
189 |
-
with open(filepath) as f:
|
190 |
-
squad = json.load(f)
|
191 |
-
for article in squad["data"]:
|
192 |
-
title = article.get("title", "").strip()
|
193 |
-
for paragraph in article["paragraphs"]:
|
194 |
-
context = paragraph["context"].strip()
|
195 |
-
for qa in paragraph["qas"]:
|
196 |
-
question = qa["question"].strip()
|
197 |
-
id_ = qa["id"]
|
198 |
-
|
199 |
-
answer_starts = [answer["answer_start"] for answer in qa["answers"]]
|
200 |
-
answers = [answer["text"].strip() for answer in qa["answers"]]
|
201 |
-
|
202 |
-
# Features currently used are "context", "question", and "answers".
|
203 |
-
# Others are extracted here for the ease of future expansions.
|
204 |
-
yield id_, {
|
205 |
-
"title": title,
|
206 |
-
"context": context,
|
207 |
-
"question": question,
|
208 |
-
"id": id_,
|
209 |
-
"answers": {"answer_start": answer_starts, "text": answers,},
|
210 |
-
}
|
|
|
171 |
|
172 |
|
173 |
|
174 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|