sergioburdisso commited on
Commit
66eb780
1 Parent(s): 8f839f6

Update dialog2flow-dataset.py

Browse files
Files changed (1) hide show
  1. dialog2flow-dataset.py +10 -6
dialog2flow-dataset.py CHANGED
@@ -176,6 +176,7 @@ class Dialog2FlowBuilder(GeneratorBasedBuilder):
176
  gen_kwargs={
177
  "file_path": file_path["train"],
178
  "split": SPLIT2NAME[split_name],
 
179
  },
180
  )
181
  )
@@ -186,9 +187,12 @@ class Dialog2FlowBuilder(GeneratorBasedBuilder):
186
  data = json.loads(f.read())
187
  return data
188
 
189
- def _generate_examples(self, file_path, split):
190
- data = self._load_json(file_path)
191
- data = [(dial_id, dial) for dial_id, dial in data["dialogs"].items() if split in dial_id]
192
- logger.info(f"generating {len(data)} examples from = {split}")
193
- for dial_id, dial in data.items():
194
- yield dial_id, {"dialog": dial}
 
 
 
 
176
  gen_kwargs={
177
  "file_path": file_path["train"],
178
  "split": SPLIT2NAME[split_name],
179
+ "split_name": split_name
180
  },
181
  )
182
  )
 
187
  data = json.loads(f.read())
188
  return data
189
 
190
+ def _generate_examples(self, file_path, split, split_name=None):
191
+ if split_name is not None:
192
+ data = self._load_json(file_path)
193
+ data = [(dial_id, dial) for dial_id, dial in data["dialogs"].items() if split_name in dial_id]
194
+ logger.info(f"generating {len(data)} examples from = {split}")
195
+ for dial_id, dial in data.items():
196
+ yield dial_id, {"dialog": dial}
197
+ else:
198
+ pass