import numpy import glob import csv from parse_cases import analysis from compare_analysis import get_dbname def filter_all_cases_checked_result(): # for i in glob.glob("/home/jiajun/Downloads/cases20230802/cases_new*_st_sqlite.csv"): for i in glob.glob("./cases_new*_st_sqlite.csv"): # for i in glob.glob("./cases_new*_st_with_equal.csv"): yield i def analysis_all(output_file, gen): m = {} with open(output_file, "w") as f: writer = csv.writer(f) row = ("dbname\tdifficulty\ttotal\tsql_equal_check_failed\traw_query_failed\tsql_run_failed\tgen_sql_failed\thuman_check\tsucceed\tsuccess_rate\twith_human_check_success_rate").split("\t") writer.writerow(row) for i in gen: dbname = get_dbname(i) for result in analysis(i): difficulty = result[0] current_value = m.get(difficulty, [0] * len(result[1:])) current_value = numpy.add(current_value, result[1:]) m[difficulty] = current_value writer.writerow([dbname, *result]) print() for difficulty in ("easy", "medium", "hard", "extra", "total"): if difficulty not in m: continue total, failed, raw_query_failed, result_failed, sql_not_found, human_check, succeed, _, _ = m[difficulty] writer.writerow(["total", difficulty, total, failed, raw_query_failed, result_failed, sql_not_found, human_check, succeed, succeed/total*100, (succeed + human_check)/total*100]) if __name__ == "__main__": output_file = "total_report.csv" analysis_all(output_file, filter_all_cases_checked_result()) # dbnames = ["new_car_1", "new_baseball_1", "new_allergy_1", "new_activity_1", "new_singer"] # dbnames = ["new_music_1"] # cases_files = ["cases_{}_st_sqlite.csv".format(i) for i in dbnames] # analysis_all(output_file, cases_files)