ccdv commited on
Commit
f85125e
1 Parent(s): 584b1af
Files changed (1) hide show
  1. QR-AN.py +20 -18
QR-AN.py CHANGED
@@ -104,17 +104,20 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
104
  DEFAULT_CONFIG_NAME = "qran_answer"
105
 
106
  def _info(self):
107
-
108
- return datasets.DatasetInfo(
109
- description=_DESCRIPTION,
110
- features=datasets.Features(
111
- {
112
- "text": datasets.Value("string"),
113
- "label": datasets.features.ClassLabel(names=_LABELS),
114
  "question": datasets.Value("string"),
115
  "answer": datasets.Value("string"),
116
  }
117
- ),
 
 
 
 
 
 
 
 
118
  supervised_keys=None,
119
  citation=_CITATION,
120
  )
@@ -124,7 +127,6 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
124
  train_path = dl_manager.download_and_extract(self._TRAIN_FILE)
125
  val_path = dl_manager.download_and_extract(self._VAL_FILE)
126
  test_path = dl_manager.download_and_extract(self._TEST_FILE)
127
- print(train_path, val_path, test_path)
128
 
129
  return [
130
  datasets.SplitGenerator(
@@ -148,13 +150,13 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
148
  label = self._LABELS_DICT[data["label_name"]]
149
 
150
  if self.config.name == "qran_generation":
151
- print("get")
152
- yield id_, {"text": "", "label": label, "question": question, "answer": answer}
153
-
154
- if self.config.name == "qran_answer":
155
- text = answer
156
- elif self.config.name == "qran_question":
157
- text = question
158
  else:
159
- text = question + " " + answer
160
- yield id_, {"text": text, "label": label, "question": "", "answer": ""}
 
 
 
 
 
 
 
104
  DEFAULT_CONFIG_NAME = "qran_answer"
105
 
106
  def _info(self):
107
+ if self.config.name == "qran_generation":
108
+ features = {
 
 
 
 
 
109
  "question": datasets.Value("string"),
110
  "answer": datasets.Value("string"),
111
  }
112
+ else:
113
+ features = {
114
+ "text": datasets.Value("string"),
115
+ "label": datasets.features.ClassLabel(names=_LABELS),
116
+ }
117
+
118
+ return datasets.DatasetInfo(
119
+ description=_DESCRIPTION,
120
+ features=datasets.Features(features),
121
  supervised_keys=None,
122
  citation=_CITATION,
123
  )
 
127
  train_path = dl_manager.download_and_extract(self._TRAIN_FILE)
128
  val_path = dl_manager.download_and_extract(self._VAL_FILE)
129
  test_path = dl_manager.download_and_extract(self._TEST_FILE)
 
130
 
131
  return [
132
  datasets.SplitGenerator(
 
150
  label = self._LABELS_DICT[data["label_name"]]
151
 
152
  if self.config.name == "qran_generation":
153
+ yield id_, {"question": question, "answer": answer}
 
 
 
 
 
 
154
  else:
155
+ if self.config.name == "qran_answer":
156
+ text = answer
157
+ elif self.config.name == "qran_question":
158
+ text = question
159
+ else:
160
+ text = question + " " + answer
161
+ yield id_, {"text": text, "label": label}
162
+