Datasets:
Commit
·
e707bc9
1
Parent(s):
df4583e
initial upload
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- convert.py +100 -0
- fragenkatalog3b_transformed.json +0 -0
- images/AB108_q.png +3 -0
- images/AB109_q.png +3 -0
- images/AB209_q.png +3 -0
- images/AB302_q.png +3 -0
- images/AB303_q.png +3 -0
- images/AB403_q.png +3 -0
- images/AB404_a.png +3 -0
- images/AB404_b.png +3 -0
- images/AB404_c.png +3 -0
- images/AB404_d.png +3 -0
- images/AB404_q.png +3 -0
- images/AB405_a.png +3 -0
- images/AB405_b.png +3 -0
- images/AB405_c.png +3 -0
- images/AB405_d.png +3 -0
- images/AB405_q.png +3 -0
- images/AB406_a.png +3 -0
- images/AB406_b.png +3 -0
- images/AB406_c.png +3 -0
- images/AB406_d.png +3 -0
- images/AB406_q.png +3 -0
- images/AB407_a.png +3 -0
- images/AB407_b.png +3 -0
- images/AB407_c.png +3 -0
- images/AB407_d.png +3 -0
- images/AB407_q.png +3 -0
- images/AB503_q.png +3 -0
- images/AB601_a.png +3 -0
- images/AB601_b.png +3 -0
- images/AB601_c.png +3 -0
- images/AB601_d.png +3 -0
- images/AC211_q.png +3 -0
- images/AC303_q.png +3 -0
- images/AC304_q.png +3 -0
- images/AC405_a.png +3 -0
- images/AC405_b.png +3 -0
- images/AC405_c.png +3 -0
- images/AC405_d.png +3 -0
- images/AC405_q.png +3 -0
- images/AC406_a.png +3 -0
- images/AC406_b.png +3 -0
- images/AC406_c.png +3 -0
- images/AC406_d.png +3 -0
- images/AC406_q.png +3 -0
- images/AC506_q.png +3 -0
- images/AC507_q.png +3 -0
- images/AC508_q.png +3 -0
- images/AC509_a.png +3 -0
convert.py
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# script used to convert original json
|
2 |
+
import json
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
def map_answer_to_index(answer_letter):
|
6 |
+
"""Convert answer letter to numerical index (0-based)"""
|
7 |
+
return {'a': 0, 'b': 1, 'c': 2, 'd': 3}[answer_letter.lower()]
|
8 |
+
|
9 |
+
def find_correct_answer(question):
|
10 |
+
"""Correct answer is always A / 0"""
|
11 |
+
return 0
|
12 |
+
|
13 |
+
def transform_question(question):
|
14 |
+
"""Transform a single question from original format to target format"""
|
15 |
+
|
16 |
+
# Base question structure
|
17 |
+
transformed = {
|
18 |
+
"language": "de",
|
19 |
+
"country": "Germany",
|
20 |
+
"file_name": "fragenkatalog3b.json",
|
21 |
+
"source": "https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Amateurfunk/Fragenkatalog/PruefungsfragenZIP.html - Prüfungsfragen zum Erwerb von Amateurfunkprüfungsbescheinigungen, Bundesnetzagentur, 3. Auflage, März 2024, (www.bundesnetzagentur.de/amateurfunk), Datenlizenz Deutschland – Namensnennung – Version 2.0 (www.govdata.de/dl-de/by-2-0)",
|
22 |
+
"license": "DL-DE->BY-2.0",
|
23 |
+
"level": f"Official Exam (Class {question['class']})",
|
24 |
+
"category_en": "Amateur Radio",
|
25 |
+
"category_original_lang": "Amateurfunk",
|
26 |
+
"original_question_num": question["number"],
|
27 |
+
"question": question["question"].strip(),
|
28 |
+
"parallel_question_id": None,
|
29 |
+
"image_png": None,
|
30 |
+
"image_information": None,
|
31 |
+
"image_type": None
|
32 |
+
}
|
33 |
+
|
34 |
+
# Handle options based on question type
|
35 |
+
if any(key.startswith('picture_') for key in question.keys()):
|
36 |
+
# Question with images
|
37 |
+
if 'picture_a' in question:
|
38 |
+
# Multiple choice with image options
|
39 |
+
transformed["options"] = [
|
40 |
+
question['picture_a'] + ".png",
|
41 |
+
question['picture_b'] + ".png",
|
42 |
+
question['picture_c'] + ".png",
|
43 |
+
question['picture_d'] + ".png"
|
44 |
+
]
|
45 |
+
else:
|
46 |
+
# Text options with question image
|
47 |
+
transformed["options"] = [
|
48 |
+
question['answer_a'].strip(),
|
49 |
+
question['answer_b'].strip(),
|
50 |
+
question['answer_c'].strip(),
|
51 |
+
question['answer_d'].strip()
|
52 |
+
]
|
53 |
+
if 'picture_question' in question:
|
54 |
+
transformed["image_png"] = question["picture_question"] + ".png"
|
55 |
+
transformed["image_information"] = "essential"
|
56 |
+
transformed["image_type"] = "diagram"
|
57 |
+
else:
|
58 |
+
# Regular text-only question
|
59 |
+
transformed["options"] = [
|
60 |
+
question['answer_a'].strip(),
|
61 |
+
question['answer_b'].strip(),
|
62 |
+
question['answer_c'].strip(),
|
63 |
+
question['answer_d'].strip()
|
64 |
+
]
|
65 |
+
|
66 |
+
# Set the correct answer
|
67 |
+
transformed["answer"] = find_correct_answer(question)
|
68 |
+
|
69 |
+
return transformed
|
70 |
+
|
71 |
+
def convert_questions(input_file):
|
72 |
+
"""Convert all questions from input file to new format"""
|
73 |
+
with open(input_file, 'r', encoding='utf-8') as f:
|
74 |
+
data = json.load(f)
|
75 |
+
|
76 |
+
transformed_questions = []
|
77 |
+
|
78 |
+
def process_section(section):
|
79 |
+
if 'questions' in section:
|
80 |
+
for q in section['questions']:
|
81 |
+
transformed_questions.append(transform_question(q))
|
82 |
+
if 'sections' in section:
|
83 |
+
for subsection in section['sections']:
|
84 |
+
process_section(subsection)
|
85 |
+
|
86 |
+
process_section(data)
|
87 |
+
|
88 |
+
return transformed_questions
|
89 |
+
|
90 |
+
def main():
|
91 |
+
input_file = Path('fragenkatalog3b.json')
|
92 |
+
output_file = input_file.with_stem(input_file.stem + '_transformed')
|
93 |
+
|
94 |
+
transformed = convert_questions(input_file)
|
95 |
+
|
96 |
+
with open(output_file, 'w', encoding='utf-8') as f:
|
97 |
+
json.dump(transformed, f, ensure_ascii=False, indent=2)
|
98 |
+
|
99 |
+
if __name__ == "__main__":
|
100 |
+
main()
|
fragenkatalog3b_transformed.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
images/AB108_q.png
ADDED
![]() |
Git LFS Details
|
images/AB109_q.png
ADDED
![]() |
Git LFS Details
|
images/AB209_q.png
ADDED
![]() |
Git LFS Details
|
images/AB302_q.png
ADDED
![]() |
Git LFS Details
|
images/AB303_q.png
ADDED
![]() |
Git LFS Details
|
images/AB403_q.png
ADDED
![]() |
Git LFS Details
|
images/AB404_a.png
ADDED
![]() |
Git LFS Details
|
images/AB404_b.png
ADDED
![]() |
Git LFS Details
|
images/AB404_c.png
ADDED
![]() |
Git LFS Details
|
images/AB404_d.png
ADDED
![]() |
Git LFS Details
|
images/AB404_q.png
ADDED
![]() |
Git LFS Details
|
images/AB405_a.png
ADDED
![]() |
Git LFS Details
|
images/AB405_b.png
ADDED
![]() |
Git LFS Details
|
images/AB405_c.png
ADDED
![]() |
Git LFS Details
|
images/AB405_d.png
ADDED
![]() |
Git LFS Details
|
images/AB405_q.png
ADDED
![]() |
Git LFS Details
|
images/AB406_a.png
ADDED
![]() |
Git LFS Details
|
images/AB406_b.png
ADDED
![]() |
Git LFS Details
|
images/AB406_c.png
ADDED
![]() |
Git LFS Details
|
images/AB406_d.png
ADDED
![]() |
Git LFS Details
|
images/AB406_q.png
ADDED
![]() |
Git LFS Details
|
images/AB407_a.png
ADDED
![]() |
Git LFS Details
|
images/AB407_b.png
ADDED
![]() |
Git LFS Details
|
images/AB407_c.png
ADDED
![]() |
Git LFS Details
|
images/AB407_d.png
ADDED
![]() |
Git LFS Details
|
images/AB407_q.png
ADDED
![]() |
Git LFS Details
|
images/AB503_q.png
ADDED
![]() |
Git LFS Details
|
images/AB601_a.png
ADDED
![]() |
Git LFS Details
|
images/AB601_b.png
ADDED
![]() |
Git LFS Details
|
images/AB601_c.png
ADDED
![]() |
Git LFS Details
|
images/AB601_d.png
ADDED
![]() |
Git LFS Details
|
images/AC211_q.png
ADDED
![]() |
Git LFS Details
|
images/AC303_q.png
ADDED
![]() |
Git LFS Details
|
images/AC304_q.png
ADDED
![]() |
Git LFS Details
|
images/AC405_a.png
ADDED
![]() |
Git LFS Details
|
images/AC405_b.png
ADDED
![]() |
Git LFS Details
|
images/AC405_c.png
ADDED
![]() |
Git LFS Details
|
images/AC405_d.png
ADDED
![]() |
Git LFS Details
|
images/AC405_q.png
ADDED
![]() |
Git LFS Details
|
images/AC406_a.png
ADDED
![]() |
Git LFS Details
|
images/AC406_b.png
ADDED
![]() |
Git LFS Details
|
images/AC406_c.png
ADDED
![]() |
Git LFS Details
|
images/AC406_d.png
ADDED
![]() |
Git LFS Details
|
images/AC406_q.png
ADDED
![]() |
Git LFS Details
|
images/AC506_q.png
ADDED
![]() |
Git LFS Details
|
images/AC507_q.png
ADDED
![]() |
Git LFS Details
|
images/AC508_q.png
ADDED
![]() |
Git LFS Details
|
images/AC509_a.png
ADDED
![]() |
Git LFS Details
|