Commit
·
c48719a
1
Parent(s):
8406a46
loading script created
Browse files- 123_test.py +20 -19
123_test.py
CHANGED
|
@@ -119,7 +119,7 @@ class FewshotPretraining(datasets.GeneratorBasedBuilder):
|
|
| 119 |
name=datasets.Split.TRAIN,
|
| 120 |
# These kwargs will be passed to _generate_examples
|
| 121 |
gen_kwargs={
|
| 122 |
-
"
|
| 123 |
"split": "train",
|
| 124 |
},
|
| 125 |
)
|
|
@@ -127,22 +127,23 @@ class FewshotPretraining(datasets.GeneratorBasedBuilder):
|
|
| 127 |
|
| 128 |
|
| 129 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 130 |
-
def _generate_examples(self,
|
| 131 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 132 |
-
print("generating {}".format(
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
| 119 |
name=datasets.Split.TRAIN,
|
| 120 |
# These kwargs will be passed to _generate_examples
|
| 121 |
gen_kwargs={
|
| 122 |
+
"file_paths": extracted_paths,
|
| 123 |
"split": "train",
|
| 124 |
},
|
| 125 |
)
|
|
|
|
| 127 |
|
| 128 |
|
| 129 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 130 |
+
def _generate_examples(self, file_paths, split):
|
| 131 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 132 |
+
print("generating {}".format(file_paths))
|
| 133 |
+
for file_path in os.listdir(file_paths):
|
| 134 |
+
with open(file_path, encoding="utf-8") as f:
|
| 135 |
+
data = pd.read_json(file_path, orient="records", lines=True)
|
| 136 |
+
for i in range(data.shape[0]):
|
| 137 |
+
row = data.iloc[i]
|
| 138 |
+
# Yields examples as (key, example) tuples
|
| 139 |
+
key = row["task"] + "_i"
|
| 140 |
+
yield key, {
|
| 141 |
+
"task": data["task"],
|
| 142 |
+
"input": data["input"],
|
| 143 |
+
"output": data["output"],
|
| 144 |
+
"options": data["options"],
|
| 145 |
+
"pageTitle": data["pageTitle"],
|
| 146 |
+
"outputColName": data["outputColName"],
|
| 147 |
+
"url": data["url"],
|
| 148 |
+
"wdcFile": data["wdcFile"],
|
| 149 |
+
}
|