File size: 2,089 Bytes
46f2aa9 |
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
train_path = ['/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/boringmeme_align_multihead',
'/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/boringmeme_cross_multihead',
'/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/irrelevantmeme_align_multihead',
'/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/irrelevantmeme_cross_multihead',
'/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/lowperformancememe_align_multihead',
'/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/lowperformancememe_cross_multihead',
'/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/text_replaced_align_multihead',
'/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/text_replaced_cross_multihead',
]
# open all the train_path, find the jsonl file end with train.jsonl, and put the dataset name into a jsonl called allmeme_multihead
import os
import json
train_data_path = {}
test_data_path = {}
for path in train_path:
for file in os.listdir(path):
if file.endswith('train.jsonl'):
# read the jsonl
with open(os.path.join(path, file), 'r') as f:
for line in f:
data = json.loads(line)
key = list(data.keys())[0]
train_data_path[key] = data[key]
if file.endswith('test.jsonl'):
# read the jsonl
with open(os.path.join(path, file), 'r') as f:
for line in f:
data = json.loads(line)
key = list(data.keys())[0]
test_data_path[key] = data[key]
# write the train_data_path into a jsonl file
with open('allmeme_multihead/allmeme_multihead_train.jsonl', 'w') as f:
f.write(json.dumps(train_data_path) + '\n')
# write the test_data_path into a jsonl file
with open('allmeme_multihead/allmeme_multihead_test.jsonl', 'w') as f:
f.write(json.dumps(test_data_path) + '\n') |