|
|
|
mode = 'jsonl' |
|
|
|
import os |
|
import json |
|
|
|
if mode == 'pretty': |
|
|
|
with open("data/dart_llm_tasks.jsonl", encoding="utf-8") as f: |
|
data = [json.loads(line) for line in f] |
|
|
|
|
|
os.makedirs("data", exist_ok=True) |
|
|
|
|
|
with open("data/dart_llm_tasks_pretty.json", "w", encoding="utf-8") as f: |
|
json.dump(data, f, ensure_ascii=False, indent=2) |
|
|
|
elif mode == 'jsonl': |
|
|
|
with open("data/dart_llm_tasks_pretty.json", encoding="utf-8") as f: |
|
data = json.load(f) |
|
|
|
|
|
with open("data/dart_llm_tasks.jsonl", "w", encoding="utf-8") as f: |
|
for item in data: |
|
f.write(json.dumps(item, ensure_ascii=False) + "\n") |
|
|
|
else: |
|
raise ValueError("Invalid mode. Choose 'pretty' or 'jsonl'") |