Update sync_from_json.py
Browse files- sync_from_json.py +20 -9
sync_from_json.py
CHANGED
@@ -1,14 +1,25 @@
|
|
1 |
-
from datasets import Dataset
|
2 |
from huggingface_hub import login
|
3 |
-
|
4 |
-
# Load the JSON file
|
5 |
import json
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
#
|
9 |
-
dataset =
|
10 |
-
dataset = dataset.rename_column("answer_text", "correct_answer")
|
11 |
-
dataset = dataset.rename_column("wrong_answers_text", "wrong_answers")
|
12 |
|
13 |
-
# Push to
|
14 |
dataset.push_to_hub("SimulaMet/NorMedQA")
|
|
|
1 |
+
from datasets import Dataset
|
2 |
from huggingface_hub import login
|
|
|
|
|
3 |
import json
|
4 |
+
# Load and process JSON data
|
5 |
+
with open("norwegian_medical_qa_v2.json") as f:
|
6 |
+
raw_data = json.load(f)
|
7 |
+
|
8 |
+
# Transform the data
|
9 |
+
processed_data = []
|
10 |
+
for item in raw_data:
|
11 |
+
wrong_answers = item["wrong_answers_text"]
|
12 |
+
# wrong_answers= [ans.strip() for ans in wrong_answers_raw.split(";")]
|
13 |
+
processed_data.append({
|
14 |
+
"question": item["question_text"],
|
15 |
+
"answer": item["answer_text"],
|
16 |
+
"wrong_answers": wrong_answers,
|
17 |
+
"source_file": item["source_file"],
|
18 |
+
"question_number": item["question_number"]
|
19 |
+
})
|
20 |
|
21 |
+
# Create Hugging Face Dataset
|
22 |
+
dataset = Dataset.from_list(processed_data)
|
|
|
|
|
23 |
|
24 |
+
# Push to the Hub
|
25 |
dataset.push_to_hub("SimulaMet/NorMedQA")
|