Update NCR.py
Browse files
NCR.py
CHANGED
@@ -97,20 +97,20 @@ class NCR(datasets.GeneratorBasedBuilder):
|
|
97 |
]
|
98 |
|
99 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
100 |
-
def _generate_examples(self,
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
97 |
]
|
98 |
|
99 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
100 |
+
def _generate_examples(self, filepath, split):
|
101 |
+
def normalize(text):
|
102 |
+
return text.replace(".", ". ").strip()
|
103 |
+
|
104 |
+
with open(filepath, encoding="utf-8") as f:
|
105 |
+
data = json.loads(f.read().decode("utf-8"))
|
106 |
+
questions = data["Questions"]
|
107 |
+
for i in range(len(questions)):
|
108 |
+
question = questions[i]
|
109 |
+
|
110 |
+
yield f"{i}", {
|
111 |
+
"example_id": data["Id"],
|
112 |
+
"article": data["Content"],
|
113 |
+
"question": question["Question"],
|
114 |
+
"answer": question["Answer"],
|
115 |
+
"options": question["Choices"],
|
116 |
+
}
|