Download dataset_script.py from xmohri/decodingthoughts: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/datasets/xmohri/decodingthoughts/resolve/d9b0a30c93e2a9e5f4e9727f92c48febca1a0788/dataset_script.py
- Command line
-
hf download hf://datasets/xmohri/decodingthoughts@d9b0a30c93e2a9e5f4e9727f92c48febca1a0788/dataset_script.py
-
curl -L -o dataset_script.py https://huggingface.co/datasets/xmohri/decodingthoughts/resolve/d9b0a30c93e2a9e5f4e9727f92c48febca1a0788/dataset_script.py
759 Bytes
| from datasets import Dataset, DatasetDict, Features, Value | |
| import os | |
| import gzip | |
| import json | |
| def load_jsonl_gz(file_path): | |
| with gzip.open(file_path, 'rt', encoding='utf-8') as f: | |
| return [json.loads(line) for line in f] | |
| def load_data(data_dir): | |
| # Adjust the paths if necessary to load all the files | |
| data_files = [os.path.join(data_dir, f) for f in os.listdir(data_dir) if f.endswith(".jsonl.gz")] | |
| data = [] | |
| for file in data_files: | |
| data.extend(load_jsonl_gz(file)) # Concatenate all jsonl.gz files | |
| return Dataset.from_dict(data) | |
| # Replace 'processed_data_gz' with the folder name | |
| def dataset_info(): | |
| return DatasetDict({ | |
| 'train': load_data('/nlp/scr/xmohri/decodingthoughts/processed_data_gz'), | |
| }) | |