import json, os from random import shuffle, seed import pandas as pd df = pd.read_csv("misc/tweet_sim.3anns-1k.tsv", sep="\t", index_col=None, header=None) tmp = [i.tolist() for i in df.values] tmp = [{"text_1": a, "text_2": b, "label_float": c} for a, b, c in tmp] seed(42) shuffle(tmp) train = tmp[:600] val = tmp[600:800] test = tmp[800:] os.makedirs("data/tweet_similarity", exist_ok=True) with open("data/tweet_similarity/train.jsonl", "w") as f: f.write("\n".join([json.dumps(i) for i in train])) with open("data/tweet_similarity/validation.jsonl", "w") as f: f.write("\n".join([json.dumps(i) for i in val])) with open("data/tweet_similarity/test.jsonl", "w") as f: f.write("\n".join([json.dumps(i) for i in test]))