| 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'), | |
| }) | |