| 23 | return output_path |
| 24 | |
| 25 | def select_items(exam_type, exam_class, num): |
| 26 | # Filter the data based on the given exam_type and exam_class |
| 27 | filtered_data = [ |
| 28 | item |
| 29 | for item in data_val |
| 30 | if item["exam_type"] == exam_type and item["exam_class"] == exam_class |
| 31 | ] |
| 32 | # Check if we have enough items |
| 33 | if len(filtered_data) < num: |
| 34 | raise ValueError(f"Not enough items matching the given criteria: {exam_type}, {exam_class}") |
| 35 | |
| 36 | # Select a random sample of items |
| 37 | selected_items = random.sample(filtered_data, num) |
| 38 | |
| 39 | return selected_items |
| 40 | |
| 41 | |
| 42 | def get_query(da, use_cot): |