def get_adjudication_data_api(): global runs_df global qrels_df global LOGS_PATH method = request.args.get('method') topic = int(request.args.get('topic')) pool_size = int(request.args.get('poolDepth')) runs_filtered = get_runs.by_topic(runs_df, topic) qrels_filtered = get_qrels.by_topic(qrels_df, topic) if method == 'round_robin': adjudication_result = round_robin.round_robin_alg( runs_filtered, qrels_filtered, pool_size, LOGS_PATH) if method == 'max_mean': adjudication_result = max_mean.max_mean_alg(runs_filtered, qrels_filtered, pool_size, LOGS_PATH) response = make_response( jsonify(adjudication_result), 200, ) response.headers["Content-Type"] = "application/json" return response
def get_runs_api(): global runs_df if (runs_df.empty or request.args.get('topic') is None): return make_response( "", 404, ) else: topic = int(request.args.get('topic')) # dataframe filtered by topic runs_filtered = get_runs.by_topic(runs_df, topic) # shorten the run size to avoid sending too large data runs_filtered = get_runs.by_run_size(runs_filtered, 100) # dataframe with index ['RANK', 'RUN'] runs_by_rank = get_runs.indexed_by_rank(runs_filtered) response = make_response( jsonify(convert_data.get_dict_from_df(runs_by_rank)), 200, ) response.headers["Content-Type"] = "application/json" return response
# parameters topic = 402 pool_size = 300 logging.basicConfig(filename=LOGS_PATH + 'round_robin.log', filemode='w', format='%(message)s', level=logging.DEBUG) pd.set_option("display.max_rows", None, "display.max_columns", 1000, "display.max_colwidth", None, "display.width", 100000) # load the txt files into a dataframe runs # print("➡️ Loading runs from file.") runs_df = convert_data.read_csv_into_df(RUNS_PATH, "RUNS", 30, 0) # load the txt files into a dataframe qrels # print("➡️ Loading qrels from file.") qrels_df = convert_data.read_csv_into_df(QRELS_PATH, "QRELS", 1, 0) # filter both runs & qrels by topic runs_filtered = get_runs.by_topic(runs_df, topic) qrels_filtered = get_qrels.by_topic(qrels_df, topic) # print("Start adjudication by pressing enter") # start_adjudication = str(input()) # round_robin.round_robin_alg(runs_filtered, qrels_filtered, pool_size, LOGS_PATH) max_mean_results = max_mean.max_mean_alg(runs_filtered, qrels_filtered, pool_size, LOGS_PATH)