ma2za commited on
Commit
a5937e9
·
1 Parent(s): 6bf028f

Upload many_emotions.py

Browse files
Files changed (1) hide show
  1. many_emotions.py +10 -8
many_emotions.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import json
2
  import os
3
  import zipfile
@@ -193,11 +194,12 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
193
  })
194
  yield uid, example
195
  elif dataset == "many_emotions":
196
- for i, filepath in enumerate(filepaths):
197
- with open(filepath, encoding="utf-8") as f:
198
- for idx, line in enumerate(f):
199
- example = json.loads(line)
200
- example.update({
201
- "label": _CLASS_NAMES[example["label"]]
202
- })
203
- yield example["id"], example
 
 
1
+ import glob
2
  import json
3
  import os
4
  import zipfile
 
194
  })
195
  yield uid, example
196
  elif dataset == "many_emotions":
197
+ for _, folder in enumerate(filepaths):
198
+ for i, filepath in glob.glob(f"{folder}/*"):
199
+ with open(filepath, encoding="utf-8") as f:
200
+ for idx, line in enumerate(f):
201
+ example = json.loads(line)
202
+ example.update({
203
+ "label": _CLASS_NAMES[example["label"]]
204
+ })
205
+ yield example["id"], example