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

Function evaluate

evaluation/test-suite-sql-eval/evaluation.py:504–778  ·  view source on GitHub ↗
(gold, predict, db_dir, etype, kmaps, plug_value, keep_distinct, progress_bar_for_each_datapoint, whether_print=False, print_file_name="")

Source from the content-addressed store, hash-verified

502
503
504def evaluate(gold, predict, db_dir, etype, kmaps, plug_value, keep_distinct, progress_bar_for_each_datapoint, whether_print=False, print_file_name=""):
505
506 with open(gold) as f:
507 glist = []
508 gseq_one = []
509 for l in f.readlines():
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 with open(predict) as f:
528 plist = []
529 pseq_one = []
530 for l in f.readlines():
531 if len(l.strip()) == 0:
532 plist.append(pseq_one)
533 pseq_one = []
534 print("lala")
535 print(l)
536 else:
537 pseq_one.append(l.strip().split('\t'))
538
539 if len(pseq_one) != 0:
540 plist.append(pseq_one)
541
542 assert len(plist) == len(glist), "number of sessions must equal"
543
544 evaluator = Evaluator()
545 turns = ['turn 1', 'turn 2', 'turn 3', 'turn 4', 'turn > 4']
546 levels = ['easy', 'medium', 'hard', 'extra', 'all', 'joint_all']
547
548 partial_types = ['select', 'select(no AGG)', 'where', 'where(no OP)', 'group(no Having)',
549 'group', 'order', 'and/or', 'IUEN', 'keywords']
550 entries = []
551 scores = {}
552
553 for turn in turns:
554 scores[turn] = {'count': 0, 'exact': 0.}
555 scores[turn]['exec'] = 0
556
557 for level in levels:
558 scores[level] = {'count': 0, 'partial': {}, 'exact': 0.}
559 scores[level]['exec'] = 0
560 for type_ in partial_types:
561 scores[level]['partial'][type_] = {'acc': 0., 'rec': 0., 'f1': 0., 'acc_count': 0, 'rec_count': 0}

Callers 1

evaluation.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