super_tweeteval / process /tweet_intimacy.py
asahi417's picture
init
285e4d9
raw
history blame
1.04 kB
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['label_float'] = 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['label_float'] = 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]))