sps commited on
Commit
060bd7e
1 Parent(s): 308e46e

Fix: for relevance single context block

Browse files
Files changed (1) hide show
  1. codequeries.py +11 -6
codequeries.py CHANGED
@@ -137,14 +137,22 @@ class Codequeries(datasets.GeneratorBasedBuilder):
137
  features["query_name"] = datasets.Value("string")
138
  features["code_file_path"] = datasets.Value("string")
139
  if self.config.name != "prefix":
140
- features["context_blocks"] = [
141
- {
142
  "content": datasets.Value("string"),
143
  "metadata": datasets.Value("string"),
144
  "header": datasets.Value("string"),
145
  "index": datasets.Value("int32")
146
  }
147
- ]
 
 
 
 
 
 
 
 
148
  features["answer_spans"] = [
149
  {
150
  'span': datasets.Value("string"),
@@ -222,13 +230,10 @@ class Codequeries(datasets.GeneratorBasedBuilder):
222
 
223
  if self.config.name == "twostep":
224
  key = 0
225
- print('File paths: ', filepath)
226
  for fp in filepath:
227
  with open(fp, encoding="utf-8") as f:
228
  for line in f:
229
- print(line)
230
  row = json.loads(line)
231
- print(row)
232
  instance_key = str(key) + "_" + row["query_name"] + "_" + row["code_file_path"]
233
  yield instance_key, {
234
  "query_name": row["query_name"],
 
137
  features["query_name"] = datasets.Value("string")
138
  features["code_file_path"] = datasets.Value("string")
139
  if self.config.name != "prefix":
140
+ if self.config.name == "twostep":
141
+ features["context_blocks"] = {
142
  "content": datasets.Value("string"),
143
  "metadata": datasets.Value("string"),
144
  "header": datasets.Value("string"),
145
  "index": datasets.Value("int32")
146
  }
147
+ else:
148
+ features["context_blocks"] = [
149
+ {
150
+ "content": datasets.Value("string"),
151
+ "metadata": datasets.Value("string"),
152
+ "header": datasets.Value("string"),
153
+ "index": datasets.Value("int32")
154
+ }
155
+ ]
156
  features["answer_spans"] = [
157
  {
158
  'span': datasets.Value("string"),
 
230
 
231
  if self.config.name == "twostep":
232
  key = 0
 
233
  for fp in filepath:
234
  with open(fp, encoding="utf-8") as f:
235
  for line in f:
 
236
  row = json.loads(line)
 
237
  instance_key = str(key) + "_" + row["query_name"] + "_" + row["code_file_path"]
238
  yield instance_key, {
239
  "query_name": row["query_name"],