| |
| import json |
| import os |
|
|
| |
| with open('default/train.json', 'r') as f: |
| data = json.load(f) |
|
|
| |
| os.makedirs('default-fixed', exist_ok=True) |
|
|
| |
| with open('default-fixed/train.jsonl', 'w') as f: |
| for i in range(len(data['file_name'])): |
| example = { |
| 'file_name': data['file_name'][i], |
| 'file_path': data['file_path'][i], |
| 'file_size': data['file_size'][i], |
| 'content_type': data['content_type'][i] |
| } |
| f.write(json.dumps(example) + '\n') |
|
|
| print(f"Converted {len(data['file_name'])} examples to JSONL format") |
|
|
| |
| with open('dataset_infos.json', 'r') as f: |
| dataset_infos = json.load(f) |
|
|
| |
| dataset_infos['default-fixed'] = dataset_infos.pop('default') |
|
|
| with open('dataset_infos.json', 'w') as f: |
| json.dump(dataset_infos, f, indent=2) |
|
|
| |
| with open('dataset_dict.json', 'r') as f: |
| dataset_dict = json.load(f) |
|
|
| |
| dataset_dict['default-fixed'] = dataset_dict.pop('default') |
|
|
| with open('dataset_dict.json', 'w') as f: |
| json.dump(dataset_dict, f, indent=2) |
|
|
| print("Updated dataset configuration files") |
|
|