File size: 456 Bytes
7e9fae4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from datasets import load_dataset

dataset = load_dataset("go_emotions", split="train")

emotions = dataset.info.features['labels'].feature.names

def query_emotion(start, end):
    rows = dataset[start:end]
    texts, labels = [rows[k] for k in rows.keys()]

    observations = []

    for i, text in enumerate(texts):
        observations.append({
            "text": text,
            "emotion": emotions[labels[i]],
        })

    return observations