File size: 759 Bytes
95d0289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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'),
    })