ccdv commited on
Commit
584b1af
1 Parent(s): aa39e4e
Files changed (1) hide show
  1. QR-AN.py +17 -27
QR-AN.py CHANGED
@@ -105,30 +105,19 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
105
 
106
  def _info(self):
107
 
108
- if self.config.name == "qran_generation":
109
- return datasets.DatasetInfo(
110
- description=_DESCRIPTION,
111
- features=datasets.Features(
112
- {
113
- "question": datasets.Value("string"),
114
- "answer": datasets.Value("string"),
115
- }
116
- ),
117
- supervised_keys=None,
118
- citation=_CITATION,
119
- )
120
- else:
121
- return datasets.DatasetInfo(
122
- description=_DESCRIPTION,
123
- features=datasets.Features(
124
- {
125
- "text": datasets.Value("string"),
126
- "label": datasets.features.ClassLabel(names=_LABELS),
127
- }
128
- ),
129
- supervised_keys=None,
130
- citation=_CITATION,
131
- )
132
 
133
 
134
  def _split_generators(self, dl_manager):
@@ -156,15 +145,16 @@ class QRANDataset(datasets.GeneratorBasedBuilder):
156
  data = json.loads(row)
157
  answer, question = data["answer"], data["question"]
158
 
 
 
159
  if self.config.name == "qran_generation":
160
  print("get")
161
- yield id_, {"question": question, "answer": answer}
162
 
163
- label = self._LABELS_DICT[data["label_name"]]
164
  if self.config.name == "qran_answer":
165
  text = answer
166
  elif self.config.name == "qran_question":
167
  text = question
168
  else:
169
  text = question + " " + answer
170
- yield id_, {"text": text, "label": label}
 
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
+ )
 
 
 
 
 
 
 
 
 
 
 
121
 
122
 
123
  def _split_generators(self, dl_manager):
 
145
  data = json.loads(row)
146
  answer, question = data["answer"], data["question"]
147
 
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": ""}