|
import json |
|
import random |
|
random.seed(42) |
|
def split_data(): |
|
f = open("./PsyQA_full.json") |
|
lines = json.load(f) |
|
random.shuffle(lines) |
|
train_data = lines[:int(len(lines)*0.8)] |
|
valid_data = lines[int(len(lines)*0.8):int(len(lines)*0.9)] |
|
test_data = lines[int(len(lines)*0.9):] |
|
print(len(train_data), len(valid_data), len(test_data)) |
|
with open("train.json", "w") as f: |
|
json.dump(train_data, f) |
|
with open("valid.json", "w") as f: |
|
json.dump(valid_data, f) |
|
with open("test.json", "w") as f: |
|
json.dump(test_data, f) |
|
split_data() |