import json import polars as pl with open("data/labels.json", "r") as f: labels = json.load(f) print(labels) test = pl.read_ndjson("data/raw_test.jsonl") train = pl.read_ndjson("data/raw_train.jsonl") print(test) print(train) test_json = [] for value in test.rows(): label, text = value print(labels[label], text) test_json.append({"label": labels[label], "text": text}) train_json = [] for value in train.rows(): label, text = value print(labels[label], text) train_json.append({"label": labels[label], "text": text}) with open("data/test.jsonl", "w") as f: f.writelines("\n".join(json.dumps(i) for i in test_json)) with open("data/train.jsonl", "w") as f: f.writelines("\n".join(json.dumps(i) for i in train_json))