| from typing import List |
| import json |
|
|
| def get_question_by_id(l,question_id): |
| doc=None |
| for i in l: |
| if i['original_question']['question_id']==question_id: |
| doc=i |
| break |
| return doc |
| def get_question_ids_with_correctness(l) -> List[str]: |
|
|
| print("started") |
| results = [] |
| for doc in l: |
| data = doc |
| question_id = data['original_question']['question_id'] |
| correct_answer = data['original_question']['answer'] |
| generated_answer = data['generated_result']['answer_key_vale'] |
| correctness = "✅" if correct_answer == generated_answer else '📛' |
| |
| results.append(f"{question_id} {correctness}") |
|
|
| return results |
|
|
| def init_json(): |
| with open("./all_data.json") as f: |
| return json.load(f) |
| def update_depth(question_id,depth): |
| with open('all_data_json' ,'w') as f: |
| l=json.load(f) |
| for i in l: |
| if i['original_question']['question_id']==question_id: |
| i["max_depth"]=depth |
| break |
| f.write(l) |