JeremyAlain commited on
Commit
c48719a
·
1 Parent(s): 8406a46

loading script created

Browse files
Files changed (1) hide show
  1. 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
- "file_path": extracted_paths,
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, file_path, 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_path))
133
- with open(file_path, encoding="utf-8") as f:
134
- data = pd.read_json(file_path, orient="records", lines=True)
135
- for i in range(data.shape[0]):
136
- row = data.iloc[i]
137
- # Yields examples as (key, example) tuples
138
- key = row["task"] + "_i"
139
- yield key, {
140
- "task": data["task"],
141
- "input": data["input"],
142
- "output": data["output"],
143
- "options": data["options"],
144
- "pageTitle": data["pageTitle"],
145
- "outputColName": data["outputColName"],
146
- "url": data["url"],
147
- "wdcFile": data["wdcFile"],
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
+ }