Spaces:
Runtime error
Runtime error
Download dataset.py from ronvolutional/http-server: direct link, hf CLI and curl.
- Browser
- Download file 443 Bytes
-
https://huggingface.co/spaces/ronvolutional/http-server/resolve/main/dataset.py
- Command line
-
hf download hf://spaces/ronvolutional/http-server/dataset.py
-
curl -L -o dataset.py https://huggingface.co/spaces/ronvolutional/http-server/resolve/main/dataset.py
443 Bytes
| from datasets import load_dataset | |
| dataset = load_dataset("emotion", split="train") | |
| emotions = dataset.info.features["label"].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 | |