import sys
import jsonlines

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from utils.json_reader import jsonl_loader

def combine_single_multi(jsonl_multi, jsonl_single, jsonl_output):
    jsonl_list_1 = jsonl_loader(jsonl_multi)
    jsonl_list_2 = jsonl_loader(jsonl_single)

    with jsonlines.open(jsonl_output,mode = "w") as w:
            
        for line_1, line_2 in zip(jsonl_list_1, jsonl_list_2):
            multi = line_1["constraint"]
            single = line_2["constraint"]
            
            new_line = line_1
            new_line["constraint"] = [multi,single]
            w.write(new_line)

if __name__ == '__main__':
    jsonl_multi = "module_03_constraint/constraint_seed_gpt/1_annotation.jsonl"
    jsonl_single = "module_03_constraint/constraint_seed_gpt/1_annotation_singular.jsonl"
    jsonl_output = "module_03_constraint/constraint_seed_gpt/1_annotation_.jsonl"
    
    combine_single_multi(jsonl_multi, jsonl_single, jsonl_output)