File size: 1,543 Bytes
a48c597 |
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 35 36 37 38 |
import pandas as pd
NUM_CONCURRENT = 40
DATASET = 'msmacro_passage'
if DATASET == 'nq':
df_irish = pd.read_json(f'data/irish_data/{DATASET}_irish.jsonl', lines=True)
df_english = pd.read_json(f'data/echo-data/{DATASET}.jsonl', lines=True)
df_english_reshuffled = []
for i in range(NUM_CONCURRENT):
curr_df_index = [idx for idx in range(len(df_english)) if idx % NUM_CONCURRENT == i]
curr_df = df_english.iloc[curr_df_index, :]
df_english_reshuffled.append(curr_df)
df_english_reshuffled = pd.concat(df_english_reshuffled)
df_english_reshuffled = df_english_reshuffled.reset_index(drop=True)
import pdb; pdb.set_trace()
df_irish['orig_query'] = df_english_reshuffled['query']
df_irish['orig_negative'] = df_english_reshuffled['negative']
df_irish['orig_positive'] = df_english_reshuffled['positive']
df_irish.to_json(f'data/irish_data/{DATASET}_irish_merged.jsonl', orient='records', lines=True, force_ascii=False)
else:
# 249592 - 178921 = 70,671
df_query = []
for i in range(2):
df = pd.read_json(f'data/irish_data/{DATASET}_{i}_irish.jsonl', lines=True)
df_query.append(df)
df_query = pd.concat(df_query)
df_query = df_query.drop(columns=['negative', 'positive'])
df_irish = pd.read_json(f'data/irish_data/{DATASET}_irish.jsonl', lines=True)
df_irish = df_irish.merge(df_query, on='query', how='left')
df_irish.to_json(f'data/irish_data/{DATASET}_irish_merged.jsonl', orient='records', lines=True, force_ascii=False)
|