File size: 734 Bytes
8fe28fd 6b445fb 8fe28fd 1fd2c38 8fe28fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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, "gold_score": c} for a, b, c in tmp]
seed(42)
shuffle(tmp)
train = tmp[:450]
val = tmp[450:550]
test = tmp[550:]
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])) |