<commit_before>/*
 * Written by <NAME> <<EMAIL>>.
 * Later rewritten by <NAME> <<EMAIL>>
 *
 * The author has dedicated the code to the public domain.  Anyone is free
 * to copy, modify, publish, use, compile, sell, or distribute the original
 * code, either in source code form or as a compiled binary, for any purpose,
 * commercial or non-commercial, and by any means.
 */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <boost/regex.hpp>
#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1

using namespace std;
using namespace boost;

/**
 * @brief SQLite3Regex, intended for storing a shared regex cache if necessary
 */
class SQLite3Regex {
private:
    // TODO: actually implement a cache
public:
    bool match(string re_str, string subject)
    {
        regex r(re_str);
        return regex_match(subject, r);
    }

    bool search(string re_str, string subject)
    {
        regex r(re_str);
        return regex_search(subject, r);
    }

    string sub(string re_str, string format, string subject)
    {
        regex r(re_str);
        return regex_replace(subject, r, format);
    }

};

extern "C" {
    /**
     * @brief Match a regular expression, giving a boolean.
     */
    void match(sqlite3_context *ctx, int argc, sqlite3_value **argv)
    {
        const char *re, *str;
        assert(argc == 2);<commit_msg>Remove std::<commit_after>#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <boost/regex.hpp>
#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1

using namespace boost;

/**
 * @brief SQLite3Regex, intended for storing a shared regex cache if necessary
 */
class SQLite3Regex {
private:
    // TODO: actually implement a cache
public:
    bool match(std::string re_str, std::string subject)
    {
        regex r(re_str);
        return regex_match(subject, r);
    }

    bool search(std::string re_str, std::string subject)
    {
        regex r(re_str);
        return regex_search(subject, r);
    }

    std::string sub(std::string re_str, std::string format, std::string subject)
    {
        regex r(re_str);
        return regex_replace(subject, r, format);
    }

};

extern "C" {
    /**
     * @brief Match a regular expression, giving a boolean.
     */
    void match(sqlite3_context *ctx, int argc, sqlite3_value **argv)
    {
        const char *re, *str;
        assert(argc == 2);
{'fraction_non_alphanumeric': 0.1155925155925156, 'fraction_numerical': 0.0058212058212058215, 'mean_word_length': 3.0436974789915965, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4060150', 'n_tokens_mistral': 768, 'n_tokens_neox': 753, 'n_words': 242}