<commit_before>/**
 * @file ir_eval_test.h
 * @author <NAME>
 */

#ifndef _META_IR_EVAL_TEST_H_
#define _META_IR_EVAL_TEST_H_

#include "inverted_index_test.h"
#include "index/eval/ir_eval.h"
#include "index/ranker/okapi_bm25.h"
#include "unit_test.h"

namespace meta
{
namespace testing
{

void ir_eval_tests()
{
    system("/usr/bin/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"};

    testing::run_test("ir-eval", [&]()
    {
        for (size_t i = 0; i < 5; ++i)
        {
            corpus::document query{idx.doc_path(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("/usr/bin/rm -rf ceeaus-inv test-config.toml");
}
}
}

#endif<commit_msg>fix type error in debug mode<commit_after>/**
 * @file ir_eval_test.h
 * @author <NAME>
 */

#ifndef _META_IR_EVAL_TEST_H_
#define _META_IR_EVAL_TEST_H_

#include "inverted_index_test.h"
#include "index/eval/ir_eval.h"
#include "index/ranker/okapi_bm25.h"
#include "unit_test.h"

namespace meta
{
namespace testing
{

void ir_eval_tests()
{
    system("/usr/bin/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"};

    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("/usr/bin/rm -rf ceeaus-inv test-config.toml");
}
}
}

#endif
{'fraction_non_alphanumeric': 0.16673614005835766, 'fraction_numerical': 0.020008336807002917, 'mean_word_length': 2.75, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1506482', 'n_tokens_mistral': 940, 'n_tokens_neox': 893, 'n_words': 166}