File size: 1,042 Bytes
285e4d9 5399d79 285e4d9 5399d79 285e4d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import os
import json
from random import shuffle, seed
import pandas as pd
os.makedirs("data/tweet_intimacy", exist_ok=True)
df_test = pd.read_csv("misc/multilingual_tweet_intimacy/test.csv")
df_test = df_test[df_test['language'] == 'English']
df_test.pop("language")
test = [i.to_dict() for _, i in df_test.iterrows()]
for i in test:
i['gold_score'] = i.pop("label")
df_train = pd.read_csv("misc/multilingual_tweet_intimacy/train.csv")
df_train = df_train[df_train['language'] == 'English']
df_train.pop("language")
train = [i.to_dict() for _, i in df_train.iterrows()]
for i in train:
i['gold_score'] = i.pop("label")
seed(42)
shuffle(train)
val = train[:len(test)]
train = train[len(test):]
with open("data/tweet_intimacy/train.jsonl", "w") as f:
f.write("\n".join([json.dumps(i) for i in train]))
with open("data/tweet_intimacy/validation.jsonl", "w") as f:
f.write("\n".join([json.dumps(i) for i in val]))
with open("data/tweet_intimacy/test.jsonl", "w") as f:
f.write("\n".join([json.dumps(i) for i in test]))
|