super_tweeteval / process /tweet_sim.py
asahi417's picture
init
6b445fb
raw
history blame
734 Bytes
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]))