ShutongFeng commited on
Commit
0315ca1
1 Parent(s): d31e9c0

Update emowoz.py

Browse files

Improve dataset output format

Files changed (1) hide show
  1. emowoz.py +23 -2
emowoz.py CHANGED
@@ -144,12 +144,33 @@ class EmoWOZ(datasets.GeneratorBasedBuilder):
144
  "multiwoz_filepath": data_dir['emowoz_multiwoz'],
145
  "dialmage_filepath": data_dir['emowoz_dialmage'],
146
  "split_filepath": data_dir['emowoz_split'],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  },
148
  )
149
  ]
150
 
151
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
152
- def _generate_examples(self, multiwoz_filepath, dialmage_filepath, split_filepath):
153
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
154
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
155
  with open(multiwoz_filepath, encoding="utf-8") as f:
@@ -161,7 +182,7 @@ class EmoWOZ(datasets.GeneratorBasedBuilder):
161
  with open(split_filepath, encoding="utf-8") as f:
162
  data_split = json.load(f)
163
 
164
- split, subset = self.config.name.split('-')
165
  if subset == 'all':
166
  dial_ids = data_split[split]['multiwoz'] + data_split[split]['dialmage']
167
  else:
 
144
  "multiwoz_filepath": data_dir['emowoz_multiwoz'],
145
  "dialmage_filepath": data_dir['emowoz_dialmage'],
146
  "split_filepath": data_dir['emowoz_split'],
147
+ "split": "train"
148
+ },
149
+ ),
150
+ datasets.SplitGenerator(
151
+ name=datasets.Split.VALIDATION,
152
+ # These kwargs will be passed to _generate_examples
153
+ gen_kwargs={
154
+ "multiwoz_filepath": data_dir['emowoz_multiwoz'],
155
+ "dialmage_filepath": data_dir['emowoz_dialmage'],
156
+ "split_filepath": data_dir['emowoz_split'],
157
+ "split": "dev"
158
+ },
159
+ ),
160
+ datasets.SplitGenerator(
161
+ name=datasets.Split.TEST,
162
+ # These kwargs will be passed to _generate_examples
163
+ gen_kwargs={
164
+ "multiwoz_filepath": data_dir['emowoz_multiwoz'],
165
+ "dialmage_filepath": data_dir['emowoz_dialmage'],
166
+ "split_filepath": data_dir['emowoz_split'],
167
+ "split": "test"
168
  },
169
  )
170
  ]
171
 
172
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
173
+ def _generate_examples(self, multiwoz_filepath, dialmage_filepath, split_filepath, split):
174
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
175
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
176
  with open(multiwoz_filepath, encoding="utf-8") as f:
 
182
  with open(split_filepath, encoding="utf-8") as f:
183
  data_split = json.load(f)
184
 
185
+ _, subset = self.config.name.split('-')
186
  if subset == 'all':
187
  dial_ids = data_split[split]['multiwoz'] + data_split[split]['dialmage']
188
  else: