Upload many_emotions.py
Browse files- 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
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
|
|
|
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
|