Update m3exam.py
Browse files
m3exam.py
CHANGED
|
@@ -17,6 +17,7 @@ _URLS = {
|
|
| 17 |
"test": "https://raw.githubusercontent.com/wicsaax/m3exam/main/afrikaans-questions-test.json",
|
| 18 |
}
|
| 19 |
|
|
|
|
| 20 |
|
| 21 |
class afrikaans(datasets.GeneratorBasedBuilder):
|
| 22 |
|
|
@@ -59,6 +60,14 @@ class afrikaans(datasets.GeneratorBasedBuilder):
|
|
| 59 |
)
|
| 60 |
]
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 63 |
def _generate_examples(self, filepath, split):
|
| 64 |
|
|
@@ -66,5 +75,5 @@ class afrikaans(datasets.GeneratorBasedBuilder):
|
|
| 66 |
print(filepath)
|
| 67 |
data = json.loads(f.read())
|
| 68 |
for idx, single_data in enumerate(data):
|
| 69 |
-
yield f"{idx}", single_data
|
| 70 |
|
|
|
|
| 17 |
"test": "https://raw.githubusercontent.com/wicsaax/m3exam/main/afrikaans-questions-test.json",
|
| 18 |
}
|
| 19 |
|
| 20 |
+
_NEED_KEY = ["question_text","background_description","answer_text","options","language"]
|
| 21 |
|
| 22 |
class afrikaans(datasets.GeneratorBasedBuilder):
|
| 23 |
|
|
|
|
| 60 |
)
|
| 61 |
]
|
| 62 |
|
| 63 |
+
def norm(self,dict):
|
| 64 |
+
new_dic = {}
|
| 65 |
+
for k,v in dict.items():
|
| 66 |
+
if k not in _NEED_KEY:
|
| 67 |
+
continue
|
| 68 |
+
new_dic[k] = v
|
| 69 |
+
return new_dic
|
| 70 |
+
|
| 71 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 72 |
def _generate_examples(self, filepath, split):
|
| 73 |
|
|
|
|
| 75 |
print(filepath)
|
| 76 |
data = json.loads(f.read())
|
| 77 |
for idx, single_data in enumerate(data):
|
| 78 |
+
yield f"{idx}", norm(single_data)
|
| 79 |
|