MCPcopy Create free account
hub / github.com/FlyingFeather/DEA-SQL / evaluate

Function evaluate

single_eval.py:505–708  ·  view source on GitHub ↗
(gold, predict, db_dir, etype, kmaps, plug_value, keep_distinct, progress_bar_for_each_datapoint)

Source from the content-addressed store, hash-verified

503
504
505def evaluate(gold, predict, db_dir, etype, kmaps, plug_value, keep_distinct, progress_bar_for_each_datapoint):
506
507 glist = []
508 gseq_one = []
509 l = gold
510 if len(l.strip()) == 0:
511 glist.append(gseq_one)
512 gseq_one = []
513 else:
514 lstrip = l.strip().split('\t')
515 gseq_one.append(lstrip)
516
517 # include the last session
518 # this was previously ignored in the SParC evaluation script
519 # which might lead to slight differences in scores
520 if len(gseq_one) != 0:
521 glist.append(gseq_one)
522
523 # spider formatting indicates that there is only one "single turn"
524 # do not report "turn accuracy" for SPIDER
525 include_turn_acc = len(glist) > 1
526
527 l = predict
528 plist = []
529 pseq_one = []
530 if len(l.strip()) == 0:
531 plist.append(pseq_one)
532 pseq_one = []
533 else:
534 pseq_one.append(l.strip().split('\t'))
535
536 if len(pseq_one) != 0:
537 plist.append(pseq_one)
538
539 assert len(plist) == len(glist), "number of sessions must equal"
540
541 evaluator = Evaluator()
542 turns = ['turn 1', 'turn 2', 'turn 3', 'turn 4', 'turn > 4']
543 levels = ['easy', 'medium', 'hard', 'extra', 'all', 'joint_all']
544
545 partial_types = ['select', 'select(no AGG)', 'where', 'where(no OP)', 'group(no Having)',
546 'group', 'order', 'and/or', 'IUEN', 'keywords']
547 entries = []
548 scores = {}
549
550 for turn in turns:
551 scores[turn] = {'count': 0, 'exact': 0.}
552 scores[turn]['exec'] = 0
553
554 for level in levels:
555 scores[level] = {'count': 0, 'partial': {}, 'exact': 0.}
556 scores[level]['exec'] = 0
557 for type_ in partial_types:
558 scores[level]['partial'][type_] = {'acc': 0., 'rec': 0., 'f1': 0., 'acc_count': 0, 'rec_count': 0}
559
560 debug = False
561 if len(plist[0]) == 1:
562 debug = True

Callers 2

save_fileMethod · 0.90
single_eval.pyFile · 0.70

Calls 11

eval_hardnessMethod · 0.95
eval_exact_matchMethod · 0.95
SchemaClass · 0.90
get_schemaFunction · 0.90
get_sqlFunction · 0.90
eval_exec_matchFunction · 0.90
EvaluatorClass · 0.70
build_valid_col_unitsFunction · 0.70
rebuild_sql_valFunction · 0.70
rebuild_sql_colFunction · 0.70
print_scoresFunction · 0.70

Tested by

no test coverage detected