def pred_human_eval():
all_preds = collections.defaultdict(list)
with open(OPTS.filename) as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
all_preds[row['Input.qid']].append(row['Answer.response'])
preds = {}
for qid in all_preds:
if OPTS.ensemble:
for a in all_preds[qid]:
count = sum(1 for pred in all_preds[qid] if a == pred)
if count > 1:
preds[qid] = a
break
else:
preds[qid] = random.sample(all_preds[qid], 1)[0]
else:
preds[qid] = random.sample(all_preds[qid], 1)[0]
print json.dumps(preds)
评论列表
文章目录