int main(void) { cfg_t *acfg, *bcfg; cfg_t *sec; acfg = create_config(); fail_unless(cfg_parse(acfg, SRC_DIR "/a.conf") == 0); bcfg = create_config(); fail_unless(cfg_parse(bcfg, SRC_DIR "/b.conf") == 0); sec = cfg_getnsec(acfg, "sec", 0); fail_unless(sec != 0); fail_unless(cfg_size(acfg, "sec") == 1); fail_unless(strcmp(cfg_title(sec), "acfg") == 0); fail_unless(cfg_getint(sec, "a") == 5); fail_unless(cfg_getint(sec, "b") == 2); sec = cfg_getnsec(bcfg, "sec", 0); fail_unless(sec != 0); fail_unless(cfg_size(bcfg, "sec") == 1); fail_unless(strcmp(cfg_title(sec), "bcfg") == 0); fail_unless(cfg_getint(sec, "a") == 1); fail_unless(cfg_getint(sec, "b") == 9); cfg_free(acfg); cfg_free(bcfg); return 0; }
int forward_index_tests() { create_config("file"); int num_failed = 0; num_failed += testing::run_test("forward-index-build-file-corpus", [&]() { system("rm -rf ceeaus-*"); ceeaus_forward_test(); }); num_failed += testing::run_test("forward-index-read-file-corpus", [&]() { ceeaus_forward_test(); system("rm -rf ceeaus-* test-config.toml"); }); create_config("line"); num_failed += testing::run_test("forward-index-build-line-corpus", [&]() { system("rm -rf ceeaus-*"); ceeaus_forward_test(); }); num_failed += testing::run_test("forward-index-read-line-corpus", [&]() { ceeaus_forward_test(); system("rm -rf ceeaus-* test-config.toml"); }); create_libsvm_config(); num_failed += testing::run_test("forward-index-build-libsvm", [&]() { system("rm -rf bcancer-*"); bcancer_forward_test(); }); num_failed += testing::run_test("forward-index-load-libsvm", [&]() { bcancer_forward_test(); system("rm -rf bcancer-* test-config.toml"); }); return num_failed; }
int ir_eval_tests() { system("rm -rf ceeaus-inv"); create_config("file"); auto idx = index::make_index<index::inverted_index, caching::splay_cache>( "test-config.toml", uint32_t{10000}); index::okapi_bm25 ranker; index::ir_eval eval{"test-config.toml"}; int num_failed = 0; num_failed += testing::run_test("ir-eval", [&]() { for (size_t i = 0; i < 5; ++i) { corpus::document query{idx->doc_path(doc_id{i}), doc_id{0}}; auto ranking = ranker.score(*idx, query); double f1 = eval.f1(ranking, query_id{i}); double p = eval.precision(ranking, query_id{i}); double r = eval.recall(ranking, query_id{i}); ASSERT(f1 >= 0 && f1 <= 1); ASSERT(p >= 0 && p <= 1); ASSERT(r >= 0 && r <= 1); } }); system("rm -rf ceeaus-inv test-config.toml"); return num_failed; }
int main (int argc, char *argv[]) { GOptionContext* context; GError *error = NULL; ihm_trick_t *ihm_setup; mtrace(); ihm_setup=malloc(sizeof(ihm_trick_t)); memset(ihm_setup,0,sizeof(ihm_trick_t)); context = g_option_context_new ( _("Gbridge GTK game") ); if(context) { //g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, entries, "gbridge"); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, &error); g_free(context); create_config(); verifie_config(); create_ihm(ihm_setup); //gtk_init (&argc, &argv); if (ihm_setup->Fenetre != NULL ) { gtk_widget_show_all(ihm_setup->Fenetre); gtk_main (); } } return (0); }
/* * init() is called when the plugin is loaded, before any other functions * are called. Put global initialization here. */ extern int init ( void ) { /* * FIXME: At the moment the smallest Cray allocation unit are still * full nodes. Node sharing (even across NUMA sockets of the same * node) is, as of CLE 3.x (Summer 2011) still not supported, i.e. * as per the LIMITATIONS section of the aprun(1) manpage of the * 3.1.27A release). * Hence for the moment we can only use select/linear. If some * time in the future this is allowable use code such as this * to make things switch to the cons_res plugin. * if (slurmctld_conf.select_type_param & CR_OTHER_CONS_RES) * plugin_id = 105; */ if (bg_recover != NOT_FROM_CONTROLLER) { if (slurmctld_conf.select_type_param & CR_OTHER_CONS_RES) { fatal("SelectTypeParams=other_cons_res is not valid " "for select/alps"); } _set_inv_interval(); } create_config(); return SLURM_SUCCESS; }
void start_core(int argc, char **argv) { int orig_argc = argc; char **orig_argv = copy_args(argc, argv); FLAGS_stderrthreshold = 0; FLAGS_logbuflevel = -1; google::ParseCommandLineFlags(&argc, &argv, true); google::InitGoogleLogging(argv[0]); auto conf = create_config(); ld_environment(orig_argv, conf.rules_directory); free_args(orig_argc, orig_argv); log_config(conf); g_core = make_real_core(conf); g_core->start(); g_core.reset(); free_thread_ns(); }
static void config_notify_handler(struct inotify_event *event, const char *ident, gpointer user_data) { char *ext; if (!ident) return; if (!g_str_has_suffix(ident, ".config")) return; ext = g_strrstr(ident, ".config"); if (!ext) return; *ext = '\0'; if (!validate_ident(ident)) { connman_error("Invalid config ident %s", ident); return; } if (event->mask & IN_CREATE) return; if (event->mask & (IN_DELETE | IN_MOVED_FROM)) { g_hash_table_remove(config_table, ident); return; } if (event->mask & (IN_MODIFY | IN_MOVED_TO)) { struct vpn_config *config; char *path = get_dir(); config = g_hash_table_lookup(config_table, ident); if (config) { g_hash_table_remove_all(config->provider_table); load_config(config, path, REMOVE); /* Re-scan the config file for any changes */ g_hash_table_remove_all(config->provider_table); load_config(config, path, ADD); } else { /* * Inotify will send create event followed by modify * event for any config file that is copied to * monitored directory. So in practice we should just * ignore the create event and trust only the modify * one in order to avoid create/remove/create loop */ config = create_config(ident); if (config) load_config(config, path, ADD); } g_free(path); } }
/* Starts wpa_supplicant. For OPEN network, pass a NULL key. */ struct wpa_process *start_wpa(char *ssid, char *key, char *iface) { struct wpa_process *process = malloc(sizeof(struct wpa_process)); bzero(process, sizeof(*process)); process->ssid = malloc(strlen(ssid)+1); strcpy(process->ssid, ssid); process->key = NULL; if (key) { process->key = malloc(strlen(key)+1); strcpy(process->key, key); } create_config(process); int p[2]; if (-1 == pipe(p)) PERROR("Unable to create child pipe"); signal(SIGCHLD, handle_chld); process->pid = fork(); if (!process->pid) { char *newargv[] = {"wpa_supplicant", "-Dwext", "-i", iface, "-c" CONFIG_FILE, NULL}; char *newargp[] = { NULL }; close(p[0]); dup2(p[1], 1); dup2(p[1], 2); close(p[1]); setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stdin, NULL, _IOLBF, 0); printf("Hi there!\n"); execve("/usr/sbin/wpa_supplicant", newargv, newargp); PERROR("Unable to exec"); exit(1); } else if(process->pid < 0) { PERROR("Unable to fork"); goto err; } close(p[1]); process->pipe = p[0]; return process; err: if (process && process->key) free(process->key); if (process && process->ssid) free(process->ssid); if (process && process->pipe) close(process->pipe); if (process && process->pid) kill(SIGTERM, process->pid); if(process) free(process); return NULL; }
int ranker_tests() { create_config("file"); system("rm -rf ceeaus-inv"); auto idx = index::make_index<index::inverted_index, caching::splay_cache>( "test-config.toml", uint32_t{10000}); auto config = cpptoml::parse_file("test-config.toml"); std::string encoding = "utf-8"; if (auto enc = config.get_as<std::string>("encoding")) encoding = *enc; int num_failed = 0; num_failed += testing::run_test("ranker-absolute-discount", [&]() { index::absolute_discount r; test_rank(r, *idx, encoding); }); num_failed += testing::run_test("ranker-dirichlet-prior", [&]() { index::dirichlet_prior r; test_rank(r, *idx, encoding); }); num_failed += testing::run_test("ranker-jelinek-mercer", [&]() { index::jelinek_mercer r; test_rank(r, *idx, encoding); }); num_failed += testing::run_test("ranker-okapi-bm25", [&]() { index::okapi_bm25 r; test_rank(r, *idx, encoding); }); num_failed += testing::run_test("ranker-pivoted-length", [&]() { index::pivoted_length r; test_rank(r, *idx, encoding); }); idx = nullptr; system("rm -rf ceeaus-inv test-config.toml"); return num_failed; }
static int read_configs(void) { GDir *dir; char *path = get_dir(); DBG("path %s", path); dir = g_dir_open(path, 0, NULL); if (dir) { const gchar *file; while ((file = g_dir_read_name(dir))) { GString *str; gchar *ident; if (!g_str_has_suffix(file, ".config")) continue; ident = g_strrstr(file, ".config"); if (!ident) continue; str = g_string_new_len(file, ident - file); if (!str) continue; ident = g_string_free(str, FALSE); if (validate_ident(ident)) { struct vpn_config *config; config = create_config(ident); if (config) load_config(config, path, ADD); } else { connman_error("Invalid config ident %s", ident); } g_free(ident); } g_dir_close(dir); } g_free(path); return 0; }
static void run(Options *options) { int socket = open_udp_socket(options->listen_port); if (options->verbose) fprintf(stderr, "Opened socket on port %d\n", options->listen_port); if (signal(SIGQUIT, handle_sigquit) == SIG_IGN) signal(SIGQUIT, SIG_IGN); reload_config = 1; while (1) { int sleep_time; if (reload_config) { if (options->config != NULL) destroy_config(options->config); options->config = load_config(options->config_filename); if (!options->config) { fprintf(stderr, "Warning: Config file cannot be read: %s\n", options->config_filename); options->config = create_config(); } initialise_config(options->config); if (options->verbose) { fprintf(stderr, "Loaded config from %s\n", options->config_filename); print_config(options->config, stderr); } reload_config = 0; } //TODO how long until the next request goes out? sleep_time = 1; input_timeout(socket, sleep_time); check_for_responses(options, socket); check_requests(options, socket); } close(socket); }
/* * init() is called when the plugin is loaded, before any other functions * are called. Put global initialization here. */ extern int init ( void ) { /* * FIXME: At the moment the smallest Cray allocation unit are still * full nodes. Node sharing (even across NUMA sockets of the same * node) is, as of CLE 3.1 (summer 2010) still not supported, i.e. * as per the LIMITATIONS section of the aprun(1) manpage of the * 3.1.27A release). * Hence for the moment we can only use select/linear. If some * time in the future this is allowable use code such as this * to make things switch to the cons_res plugin. * if (slurmctld_conf.select_type_param & CR_CONS_RES) * plugin_id = 105; */ create_config(); return SLURM_SUCCESS; }
int pmd_system_init() { create_config(); if (config_open() != 0) { return 1; } if(can_net_init(10000000, 100) != 0) { return 2; } interrupt_init(); if(net_device_init() != 0) { return 3; } //Non-smb message handler cb_records[0].check.port_min = 0; cb_records[0].check.port_max = -1; cb_records[0].check.id_min = 0; cb_records[0].check.id_max = -1; cb_records[0].check.smb_min = 0; cb_records[0].check.smb_max = 0; cb_records[0].callback = non_smb_net_cb; cb_records[0].cb_ctx = NULL; //smb message handler cb_records[1].check.port_min = 0; cb_records[1].check.port_max = -1; cb_records[1].check.id_min = 0; cb_records[1].check.id_max = -1; cb_records[1].check.smb_min = 1; cb_records[1].check.smb_max = 1; cb_records[1].callback = smb_net_cb; cb_records[1].cb_ctx = NULL; can_net_add_callback( &(cb_records[0]) ); can_net_add_callback( &(cb_records[1]) ); operation_mode = OPERATION_MODE_NORMAL; heartbeat_msg_init(&heartbeat_msg); ftimer_register_func(send_heartbeat, NULL, 1000); return 0; }
/* check for ~./nccc/nccc.conf and create one if there is none */ int init_config() { DIR *dir; struct dirent *dir_list; char *confdir=""; get_homedir(); confdir = strdup(homedir); strcat(confdir, "/.nccc"); /* open config directory */ if((dir = opendir(confdir)) == NULL) { /* it does not exist, create it */ if(mkdir(confdir, 0700) < 0) { perror("Fehler beim erstellen des config-Verzeichnisses"); return 110; } if((dir = opendir(confdir)) == NULL) { perror("Fehler beim oeffnen des config-Verzeichnisses"); return 111; } } /* it exists, now look for the config-file */ while((dir_list = readdir(dir)) != NULL) { if(strcmp(dir_list->d_name, "nccc.conf") == 0) { /* config-file found ! */ return 0; } } if(create_config() != 0) { return 112; } return 0; }
int ir_eval_bounds() { return testing::run_test( "ir-eval-bounds", [&]() { system("rm -rf ceeaus-inv"); create_config("file"); auto idx = index::make_index<index::inverted_index, caching::splay_cache>( "test-config.toml", uint32_t{10000}); index::okapi_bm25 ranker; index::ir_eval eval{"test-config.toml"}; // sanity test bounds for (size_t i = 0; i < 5; ++i) { corpus::document query{idx->doc_path(doc_id{i}), doc_id{0}}; auto ranking = ranker.score(*idx, query); auto f1 = eval.f1(ranking, query_id{i}); auto p = eval.precision(ranking, query_id{i}); auto r = eval.recall(ranking, query_id{i}); auto avg_p = eval.avg_p(ranking, query_id{i}); auto ndcg = eval.ndcg(ranking, query_id{i}); ASSERT(f1 >= 0 && f1 <= 1); ASSERT(p >= 0 && p <= 1); ASSERT(r >= 0 && r <= 1); ASSERT(avg_p >= 0 && avg_p <= 1); ASSERT(ndcg >= 0 && ndcg <= 1); } auto map = eval.map(); auto gmap = eval.gmap(); ASSERT(map >= 0 && map <= 1); ASSERT(gmap >= 0 && gmap <= 1); system("rm -rf ceeaus-inv test-config.toml"); }); }
static DBusMessage *create_proxy_config(DBusConnection *conn, DBusMessage *msg, void *user_data) { DBusMessage *reply; DBusMessageIter iter, array; struct proxy_config *config; const char *sender, *method = NULL, *interface = NULL; const char *url = NULL, *script = NULL; char **servers = NULL, **excludes = NULL; char **domains = NULL, **nameservers = NULL; sender = dbus_message_get_sender(msg); dbus_message_iter_init(msg, &iter); dbus_message_iter_recurse(&iter, &array); while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) { DBusMessageIter entry, value, list; const char *key; dbus_message_iter_recurse(&array, &entry); dbus_message_iter_get_basic(&entry, &key); dbus_message_iter_next(&entry); dbus_message_iter_recurse(&entry, &value); switch (dbus_message_iter_get_arg_type(&value)) { case DBUS_TYPE_STRING: if (g_str_equal(key, "Method")) { dbus_message_iter_get_basic(&value, &method); if (strlen(method) == 0) method = NULL; } else if (g_str_equal(key, "URL")) { dbus_message_iter_get_basic(&value, &url); if (strlen(url) == 0) url = NULL; } else if (g_str_equal(key, "Script")) { dbus_message_iter_get_basic(&value, &script); if (strlen(script) == 0) script = NULL; } else if (g_str_equal(key, "Interface")) { dbus_message_iter_get_basic(&value, &interface); if (strlen(interface) == 0) interface = NULL; } break; case DBUS_TYPE_ARRAY: dbus_message_iter_recurse(&value, &list); if (dbus_message_iter_get_arg_type(&list) == DBUS_TYPE_INVALID) break; if (g_str_equal(key, "Servers")) { g_strfreev(servers); servers = extract_string_array(&list); } else if (g_str_equal(key, "Excludes")) { g_strfreev(excludes); excludes = extract_string_array(&list); } else if (g_str_equal(key, "Domains")) { g_strfreev(domains); domains = extract_string_array(&list); } else if (g_str_equal(key, "Nameservers")) { g_strfreev(nameservers); nameservers = extract_string_array(&list); } break; } dbus_message_iter_next(&array); } DBG("sender %s method %s interface %s", sender, method, interface); DBG("url %s script %p", url, script); if (!method) { reply = g_dbus_create_error(msg, PACRUNNER_ERROR_INTERFACE ".Failed", "No proxy method specified"); goto done; } config = create_config(conn, sender, interface); if (!config) { reply = g_dbus_create_error(msg, PACRUNNER_ERROR_INTERFACE ".Failed", "Memory allocation failed"); goto done; } config->domains = domains; config->nameservers = nameservers; domains = NULL; nameservers = NULL; if (g_str_equal(method, "direct")) { if (pacrunner_proxy_set_direct(config->proxy) < 0) pacrunner_error("Failed to set direct proxy"); } else if (g_str_equal(method, "manual")) { if (pacrunner_proxy_set_manual(config->proxy, servers, excludes) < 0) pacrunner_error("Failed to set proxy servers"); } else if (g_str_equal(method, "auto")) { if (pacrunner_proxy_set_auto(config->proxy, url, script) < 0) pacrunner_error("Failed to set auto proxy"); } else { destroy_config(config); reply = g_dbus_create_error(msg, PACRUNNER_ERROR_INTERFACE ".Failed", "Invalid proxy method specified"); goto done; } g_hash_table_insert(config_list, config->path, config); reply = g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &config->path, DBUS_TYPE_INVALID); done: g_strfreev(servers); g_strfreev(excludes); g_strfreev(domains); g_strfreev(nameservers); return reply; }
nodes_data::ptr start_nodes(std::ostream &debug_stream, const std::vector<config_data> &configs, const std::string &path) { nodes_data::ptr data = std::make_shared<nodes_data>(); std::string base_path; std::string auth_cookie; std::string cocaine_config_template = read_file(COCAINE_CONFIG_PATH); std::string run_path; { char buffer[1024]; snprintf(buffer, sizeof(buffer), "%04x%04x", rand(), rand()); buffer[sizeof(buffer) - 1] = 0; auth_cookie = buffer; snprintf(buffer, sizeof(buffer), "/tmp/elliptics-test-run-%04x/", rand()); buffer[sizeof(buffer) - 1] = 0; run_path = buffer; } const auto ports = generate_ports(configs.size()); if (path.empty()) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "/tmp/elliptics-test-%04x/", rand()); buffer[sizeof(buffer) - 1] = 0; base_path = buffer; create_directory(base_path); data->directory = directory_handler(base_path, true); } else { base_path = path; create_directory(base_path); data->directory = directory_handler(base_path, false); } debug_stream << "Set base directory: \"" << base_path << "\"" << std::endl; create_directory(run_path); data->run_directory = directory_handler(run_path, true); debug_stream << "Set cocaine run directory: \"" << run_path << "\"" << std::endl; std::string cocaine_remotes; for (size_t j = 0; j < configs.size(); ++j) { if (j > 0) cocaine_remotes += ", "; cocaine_remotes += "\"localhost\": " + ports[j]; } const auto cocaine_locator_ports = generate_ports(configs.size()); // client only needs connection to one (any) locator service data->locator_port = std::stoul(cocaine_locator_ports[0]); debug_stream << "Starting " << configs.size() << " servers" << std::endl; for (size_t i = 0; i < configs.size(); ++i) { debug_stream << "Starting server #" << (i + 1) << std::endl; const std::string server_path = base_path + "/server-" + boost::lexical_cast<std::string>(i + 1); create_directory(server_path); create_directory(server_path + "/blob"); create_directory(server_path + "/history"); std::string remotes; for (size_t j = 0; j < configs.size(); ++j) { if (j == i) continue; remotes += create_remote(ports[j]); } config_data config = configs[i]; if (remotes.empty()) config("remote", NULL_VALUE); else config("remote", remotes); if (config.has_value("srw_config")) { create_directory(server_path + "/run"); const substitute_context cocaine_variables = { { "COCAINE_LOCATOR_PORT", cocaine_locator_ports[i] }, { "COCAINE_PLUGINS_PATH", COCAINE_PLUGINS_PATH }, { "ELLIPTICS_REMOTES", cocaine_remotes }, { "ELLIPTICS_GROUPS", "1" }, { "COCAINE_LOG_PATH", server_path + "/cocaine.log" }, { "COCAINE_RUN_PATH", run_path } }; create_cocaine_config(server_path + "/cocaine.conf", cocaine_config_template, cocaine_variables); config("srw_config", server_path + "/cocaine.conf"); } create_config(config, server_path + "/ioserv.conf") ("auth_cookie", auth_cookie) ("log", server_path + "/log.log") ("addr", create_remote(ports[i])) ("history", server_path + "/history") ("data", server_path + "/blob/data") ; server_node server(server_path + "/ioserv.conf", create_remote(ports[i])); server.start(); debug_stream << "Started server #" << (i + 1) << std::endl; data->nodes.emplace_back(std::move(server)); } { std::vector<std::string> remotes; for (size_t i = 0; i < data->nodes.size(); ++i) { remotes.push_back(data->nodes[i].remote()); } start_client_nodes(data, debug_stream, remotes); } return data; }
int ir_eval_results() { return testing::run_test( "ir-eval-results", [&]() { create_config("file"); index::ir_eval eval{"test-config.toml"}; ASSERT_APPROX_EQUAL(eval.map(), 0.0); ASSERT_APPROX_EQUAL(eval.gmap(), 0.0); // make some fake results based on the loaded qrels file std::vector<std::pair<doc_id, double>> results; query_id qid{0}; auto idcg_5 = 1.0 + 1.0 / std::log2(3.0) + 1.0 / std::log2(4.0) + 1.0 / std::log2(5.0) + 1.0 / std::log2(6.0); auto idcg = idcg_5 + 1.0 / std::log2(7.0) + 1.0 / std::log2(8.0) + 1.0 / std::log2(9.0) + 1.0 / std::log2(10.0) + 1.0 / std::log2(11.0); results.emplace_back(doc_id{0}, 1.0); // relevant check_query(eval, results, qid, 0.2 / 1.1, 1, 0.1, 0.1, 1.0 / idcg); check_query(eval, results, qid, 0.2 / 1.1, 1, 0.1, 0.2, 1.0 / idcg_5, 5); results.emplace_back(doc_id{2}, 0.9); // not relevant check_query(eval, results, qid, 0.1 / 0.6, 0.5, 0.1, 0.1, 1.0 / idcg); check_query(eval, results, qid, 0.1 / 0.6, 0.5, 0.1, 0.2, 1.0 / idcg_5, 5); results.emplace_back(doc_id{1}, 0.8); // relevant check_query(eval, results, qid, (2.0 * (2.0 / 3.0) * 0.2) / (2.0 / 3.0 + 0.2), 2.0 / 3.0, 0.2, 1.0 / 6.0, 1.5 / idcg); check_query(eval, results, qid, (2.0 * (2.0 / 3.0) * 0.2) / (2.0 / 3.0 + 0.2), 2.0 / 3.0, 0.2, 1.0 / 3.0, 1.5 / idcg_5, 5); results.emplace_back(doc_id{30}, 0.8); // relevant results.emplace_back(doc_id{6}, 0.7); // relevant results.emplace_back(doc_id{43}, 0.6); // relevant results.emplace_back(doc_id{24}, 0.5); // relevant results.emplace_back(doc_id{34}, 0.4); // relevant results.emplace_back(doc_id{35}, 0.3); // relevant results.emplace_back(doc_id{38}, 0.2); // relevant results.emplace_back(doc_id{754}, 0.1); // relevant auto avg_p_5 = (1.0 + 2.0 / 3.0 + 3.0 / 4.0 + 4.0 / 5.0 + 5.0 / 6.0) / 5.0; auto avg_p = (1.0 + 2.0 / 3.0 + 3.0 / 4.0 + 4.0 / 5.0 + 5.0 / 6.0 + 6.0 / 7.0 + 7.0 / 8.0 + 8.0 / 9.0 + 9.0 / 10.0 + 10.0 / 11.0) / 10.0; auto dcg_5 = 1.0 + 1.0 / std::log2(4.0) + 1.0 / std::log2(5.0) + 1.0 / std::log2(6.0); // 4 terms, 1 zero term auto dcg = dcg_5 + 1.0 / std::log2(7.0) + 1.0 / std::log2(8.0) + 1.0 / std::log2(9.0) + 1.0 / std::log2(10.0) + 1.0 / std::log2(11.0) + 1.0 / std::log2(12.0); check_query(eval, results, qid, (2.0 * (10.0 / 11.0)) / ((10.0 / 11.0) + 1.0), 10.0 / 11.0, 1.0, avg_p, dcg / idcg); check_query(eval, results, qid, (2.0 * (4.0 / 5.0) * 0.4) / ((4.0 / 5.0) + 0.4), 4.0 / 5.0, 0.4, avg_p_5, dcg_5 / idcg_5, 5); results.erase(results.begin() + 1); // remove non-relevant result check_query(eval, results, qid, 1.0, 1.0, 1.0, 1.0, 1.0); // recall is still not perfect @5 check_query(eval, results, qid, 1.0 / 1.5, 1.0, 0.5, 1.0, 1.0, 5); system("rm test-config.toml"); }); }