File size: 587 Bytes
f02ca70 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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() |