import json
import os
import time

# load each json in data/train
data_dir = "./data/train"
data_list = os.listdir(data_dir)
for data in data_list:
    with open(os.path.join(data_dir, data)) as file:
        thy_series = json.load(file)
    Q = thy_series['problem']
    A = thy_series['solution']
    answer = thy_series['answer']
    #### check the formal problem
    thy = thy_series.get(f'generation_39', {})
    # if thy == {}:
        # thy['formal problem'] = thy_series.get("formal problem", "")
        # thy['answer'] = thy_series.get("check", "")
    p = thy_series.get("problem", "")
    a = thy_series.get("answer", "")
    fp = thy_series.get("formal problem", "")
    thy['informal problem'] = p
    thy['answer'] = a
    thy['formal problem'] = fp
    thy_series[f'generation_35'] = thy
    with open(os.path.join(data_dir, data), 'w') as file:
        json.dump(thy_series, file, indent=4)