File size: 765 Bytes
450a449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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))