NetsPresso_QA / convert_cast22_eval_json_to_queries_tsv.py
geonmin-kim's picture
Upload folder using huggingface_hub
d6585f5
raw
history blame contribute delete
729 Bytes
import json
from tqdm import tqdm
### read: cast 22 eval json
eval_json_path="/root/Corpus/CAsT22_eval_queries/cqr_inferred_results.json"
# read data
with open(eval_json_path, 'r') as fr:
data = json.load(fr)
# write: queries.tsv (format: {qid}\t{query})
eval_queries_path = "/root/Corpus/CAsT22_eval_queries/queries_cqr_result.tsv"
with open(eval_queries_path, 'w') as fw:
for sample in tqdm(data):
conv_id = sample['number']
for turn in sample['turn']:
turn_id = turn['number']
automatic_rewritten_utterance = turn['automatic_rewritten_utterance']
q_id = f"{conv_id}_{turn_id}"
fw.write(f"{q_id}\t{automatic_rewritten_utterance}\n")