Update modules/dataset.py
Browse files- modules/dataset.py +6 -9
modules/dataset.py
CHANGED
@@ -2,18 +2,15 @@ from datasets import load_dataset
|
|
2 |
|
3 |
dataset = load_dataset("go_emotions", split="train")
|
4 |
|
5 |
-
emotions = dataset.info.features[
|
|
|
6 |
|
7 |
def query_emotion(start, end):
|
8 |
rows = dataset[start:end]
|
9 |
-
texts, labels, id = [rows[k] for k in rows.keys()]
|
10 |
-
|
11 |
-
observations = []
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
})
|
18 |
|
19 |
return observations
|
|
|
2 |
|
3 |
dataset = load_dataset("go_emotions", split="train")
|
4 |
|
5 |
+
emotions = dataset.info.features["labels"].feature.names
|
6 |
+
|
7 |
|
8 |
def query_emotion(start, end):
|
9 |
rows = dataset[start:end]
|
|
|
|
|
|
|
10 |
|
11 |
+
observations = [
|
12 |
+
{"text": r[0], "emotion": emotions[r[1][0]]}
|
13 |
+
for r in zip(rows["text"], rows["labels"])
|
14 |
+
]
|
|
|
15 |
|
16 |
return observations
|