ccdv commited on
Commit
20b80dd
1 Parent(s): 774d330
Files changed (1) hide show
  1. QR-AN.py +26 -16
QR-AN.py CHANGED
@@ -103,20 +103,30 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
103
  DEFAULT_CONFIG_NAME = "qran_answer"
104
 
105
  def _info(self):
106
- return datasets.DatasetInfo(
107
- description=_DESCRIPTION,
108
- features=datasets.Features(
109
- {
110
- "text": datasets.Value("string"),
111
- "question": datasets.Value("string"),
112
- "answer": datasets.Value("string"),
113
- #"label_name": datasets.Value("string"),
114
- "label": datasets.features.ClassLabel(names=_LABELS),
115
- }
116
- ),
117
- supervised_keys=None,
118
- citation=_CITATION,
119
- )
 
 
 
 
 
 
 
 
 
 
120
 
121
  def _split_generators(self, dl_manager):
122
  train_path = dl_manager.download_and_extract(self._DOWNLOAD_URL + self._TRAIN_FILE)
@@ -144,7 +154,7 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
144
  label = self._LABELS_DICT[data["label_name"]]
145
 
146
  if self.config.name == "qran_generation":
147
- yield id_, {"text": None, "label": None, "question": question, "answer": answer}
148
 
149
  if self.config.name == "qran_answer":
150
  text = answer
@@ -152,4 +162,4 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
152
  text = question
153
  else:
154
  text = question + " " + answer
155
- yield id_, {"text": text, "label": label, "question": None, "answer": None}
 
103
  DEFAULT_CONFIG_NAME = "qran_answer"
104
 
105
  def _info(self):
106
+ if self.config.name == "qran_generation":
107
+ return datasets.DatasetInfo(
108
+ description=_DESCRIPTION,
109
+ features=datasets.Features(
110
+ {
111
+ "question": datasets.Value("string"),
112
+ "answer": datasets.Value("string"),
113
+ }
114
+ ),
115
+ supervised_keys=None,
116
+ citation=_CITATION,
117
+ )
118
+ else:
119
+ return datasets.DatasetInfo(
120
+ description=_DESCRIPTION,
121
+ features=datasets.Features(
122
+ {
123
+ "text": datasets.Value("string"),
124
+ "label": datasets.features.ClassLabel(names=_LABELS),
125
+ }
126
+ ),
127
+ supervised_keys=None,
128
+ citation=_CITATION,
129
+ )
130
 
131
  def _split_generators(self, dl_manager):
132
  train_path = dl_manager.download_and_extract(self._DOWNLOAD_URL + self._TRAIN_FILE)
 
154
  label = self._LABELS_DICT[data["label_name"]]
155
 
156
  if self.config.name == "qran_generation":
157
+ yield id_, {"question": question, "answer": answer}
158
 
159
  if self.config.name == "qran_answer":
160
  text = answer
 
162
  text = question
163
  else:
164
  text = question + " " + answer
165
+ yield id_, {"text": text, "label": label}