Update soybean_dataset.py
Browse files- soybean_dataset.py +3 -38
soybean_dataset.py
CHANGED
@@ -21,10 +21,10 @@ import os
|
|
21 |
from typing import List
|
22 |
import datasets
|
23 |
import logging
|
24 |
-
|
25 |
import numpy as np
|
26 |
from PIL import Image
|
27 |
-
|
28 |
import io
|
29 |
import pandas as pd
|
30 |
import matplotlib.pyplot as plt
|
@@ -191,39 +191,4 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
191 |
|
192 |
|
193 |
|
194 |
-
|
195 |
-
#### origin
|
196 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
197 |
-
urls_to_download = self._URLS
|
198 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
199 |
-
|
200 |
-
return [
|
201 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
202 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
203 |
-
]
|
204 |
-
|
205 |
-
def _generate_examples(self, filepath):
|
206 |
-
"""This function returns the examples in the raw (text) form."""
|
207 |
-
logging.info("generating examples from = %s", filepath)
|
208 |
-
with open(filepath) as f:
|
209 |
-
squad = json.load(f)
|
210 |
-
for article in squad["data"]:
|
211 |
-
title = article.get("title", "").strip()
|
212 |
-
for paragraph in article["paragraphs"]:
|
213 |
-
context = paragraph["context"].strip()
|
214 |
-
for qa in paragraph["qas"]:
|
215 |
-
question = qa["question"].strip()
|
216 |
-
id_ = qa["id"]
|
217 |
-
|
218 |
-
answer_starts = [answer["answer_start"] for answer in qa["answers"]]
|
219 |
-
answers = [answer["text"].strip() for answer in qa["answers"]]
|
220 |
-
|
221 |
-
# Features currently used are "context", "question", and "answers".
|
222 |
-
# Others are extracted here for the ease of future expansions.
|
223 |
-
yield id_, {
|
224 |
-
"title": title,
|
225 |
-
"context": context,
|
226 |
-
"question": question,
|
227 |
-
"id": id_,
|
228 |
-
"answers": {"answer_start": answer_starts, "text": answers,},
|
229 |
-
}
|
|
|
21 |
from typing import List
|
22 |
import datasets
|
23 |
import logging
|
24 |
+
|
25 |
import numpy as np
|
26 |
from PIL import Image
|
27 |
+
|
28 |
import io
|
29 |
import pandas as pd
|
30 |
import matplotlib.pyplot as plt
|
|
|
191 |
|
192 |
|
193 |
|
194 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|