Update SPACCC.py
Browse files
SPACCC.py
CHANGED
|
@@ -25,27 +25,34 @@ class MyDataset(datasets.GeneratorBasedBuilder):
|
|
| 25 |
return datasets.DatasetInfo() # features inferred automatically from Parquet
|
| 26 |
|
| 27 |
def _split_generators(self, dl_manager):
|
| 28 |
-
|
| 29 |
-
data_dir = self.config.name + "_data"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
return [
|
| 31 |
datasets.SplitGenerator(
|
| 32 |
name=datasets.Split.TRAIN,
|
| 33 |
-
gen_kwargs={"filepath":
|
| 34 |
),
|
| 35 |
datasets.SplitGenerator(
|
| 36 |
name=datasets.Split.VALIDATION,
|
| 37 |
-
gen_kwargs={"filepath":
|
| 38 |
),
|
| 39 |
datasets.SplitGenerator(
|
| 40 |
name=datasets.Split.TEST,
|
| 41 |
-
gen_kwargs={"filepath":
|
| 42 |
),
|
| 43 |
]
|
| 44 |
-
|
| 45 |
def _generate_examples(self, filepath):
|
| 46 |
import pyarrow.parquet as pq
|
| 47 |
table = pq.read_table(filepath)
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
for idx in range(num_rows):
|
| 51 |
-
yield idx, {key: df[key][idx] for key in df}
|
|
|
|
| 25 |
return datasets.DatasetInfo() # features inferred automatically from Parquet
|
| 26 |
|
| 27 |
def _split_generators(self, dl_manager):
|
| 28 |
+
|
| 29 |
+
data_dir = self.config.name + "_data"
|
| 30 |
+
|
| 31 |
+
data_files = {
|
| 32 |
+
"train": os.path.join(data_dir, "train-00000-of-00001.parquet"),
|
| 33 |
+
"validation": os.path.join(data_dir, "validation-00000-of-00001.parquet"),
|
| 34 |
+
"test": os.path.join(data_dir, "test-00000-of-00001.parquet"),
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
downloaded_files = dl_manager.download(data_files)
|
| 38 |
+
|
| 39 |
return [
|
| 40 |
datasets.SplitGenerator(
|
| 41 |
name=datasets.Split.TRAIN,
|
| 42 |
+
gen_kwargs={"filepath": downloaded_files["train"]},
|
| 43 |
),
|
| 44 |
datasets.SplitGenerator(
|
| 45 |
name=datasets.Split.VALIDATION,
|
| 46 |
+
gen_kwargs={"filepath": downloaded_files["validation"]},
|
| 47 |
),
|
| 48 |
datasets.SplitGenerator(
|
| 49 |
name=datasets.Split.TEST,
|
| 50 |
+
gen_kwargs={"filepath": downloaded_files["test"]},
|
| 51 |
),
|
| 52 |
]
|
| 53 |
+
|
| 54 |
def _generate_examples(self, filepath):
|
| 55 |
import pyarrow.parquet as pq
|
| 56 |
table = pq.read_table(filepath)
|
| 57 |
+
for i in range(table.num_rows):
|
| 58 |
+
yield i, table.slice(i, 1).to_pydict()
|
|
|
|
|
|