ORIG_DATASET_PATH="../1_raw_dataset/topicattack/data/crafted_instruction_data_squad_injection_qa_llama_filtered_dev.json"
OUT_PATH="inj-squid_head_ident_llama_filtered_dev.jsonl"
import json
datas = json.loads(open(ORIG_DATASET_PATH).read())

out_file = open(OUT_PATH,"w")

def craft_get_data(data):
    inst = data["instruction"]
    data = data["input"]
    if len(data.split(" ")) < 3:
        return
    inst_data = f"<inst>{inst}</inst> <data>{data}</data>"
    inv_inst_data = f"<data>{data}</data> <inst>{inst}</inst>"
    out_file.write(json.dumps([inst_data,inv_inst_data]) + "\n")
for data in datas:
    craft_get_data(data)