<commit_before><?php
/**
* QHM インストーラー
*/
define('INSTALL_DIR', dirname(__FILE__));
define('ARCHIVE_URL', 'https://github.com/open-qhm/qhm/archive/master.zip');
define('DEVELOPMENT', false);

// require src/func.php
function copy_qhm_files($source, $dist)
{
    $source = rtrim($source, '/');
    $dist   = rtrim($dist, '/');
    // $dist が存在し、かつフォルダでない場合エラー
    if (file_exists($dist) && ! is_dir($dist)) {
        return false;
    }

    if ( ! file_exists($dist)) {
        mkdir($dist);
    }

    $files = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS),
        RecursiveIteratorIterator::SELF_FIRST
    );

    $base_path = '';
    $index = 0;

    foreach ($files as $file)
    {
        // 最初のパス（qhm-master）は基準として使う
        if ($base_path === '') {
            $base_path = $file->getPathname() . '/';
            $index = strlen($base_path);
        } else {
            $file_path = $file->getPathname();
            $relative_path = substr($file_path, $index);
            // .htaccess は除外する
            $exclude_ptn = '/
                \A\.htaccess\z
            /x';
            if (preg_match($exclude_ptn, $relative_path)) {
                continue;
            }

            if ($file->isDir()) {
                mkdir($dist . '/' . $relative_path);
            } else {
                copy($file_path, $dist . '/' . $relative_path);
            }
        }
    }

    return true;
}

function delete_files($dir)
{
    if ( ! file_exists($dir)) return;

    $files = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS),
        RecursiveIteratorIterator::CHILD_FIRST
    );

    foreach ($files as $file)
    {
        if ($file->isDir() === true)
        {
            rmdir($file->getPathname());
        }<commit_msg>Update install.php<commit_after><?php
/**
* QHM インストーラー
*/
define('INSTALL_DIR', dirname(__FILE__));
define('ARCHIVE_URL', 'https://github.com/open-qhm/qhm/archive/master.zip');
define('DEVELOPMENT', false);

// require src/func.php
function copy_qhm_files($source, $dist)
{
    $source = rtrim($source, '/');
    $dist   = rtrim($dist, '/');
    // $dist が存在し、かつフォルダでない場合エラー
    if (file_exists($dist) && ! is_dir($dist)) {
        return false;
    }

    if ( ! file_exists($dist)) {
        mkdir($dist);
    }

    $files = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS),
        RecursiveIteratorIterator::SELF_FIRST
    );

    $base_path = '';
    $index = 0;

    $htaccess_path = '';
    foreach ($files as $file)
    {
        // 最初のパス（qhm-master）は基準として使う
        if ($base_path === '') {
            $base_path = $file->getPathname() . '/';
            $index = strlen($base_path);
        } else {
            $file_path = $file->getPathname();
            $relative_path = substr($file_path, $index);
            // .htaccess は除外する
            $exclude_ptn = '/
                \A\.htaccess\z
            /x';
            if (preg_match($exclude_ptn, $relative_path)) {
                $htaccess_path = $file->getPathname();
                continue;
            }

            if ($file->isDir()) {
                $path = $dist . '/' . $relative_path;
                if ( ! file_exists($path))
                    mkdir($path);
            } else {
                copy($file_path, $dist . '/' . $relative_path);
            }
        }
    }

    // .htaccess を追記する
    if ($htaccess_path) {
        if (file_exists('.htaccess')) {
            file_put_contents('.htaccess',
                file_get_contents('.htaccess') . "\n" .
                file_get_contents($htaccess_path));
        } else {
            copy($htaccess_path, '.htaccess');
        }
    }

    return true;
}

function delete_files($dir)
{
    if ( ! file_exists($dir)) return;

    $files = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS),
        RecursiveIteratorIterator::CHILD_FIRST
    );

    foreach ($files as $file)
    {
        if ($file->isDir() === true)
        {
            rmdir($file->getPathname());
        }
{'fraction_non_alphanumeric': 0.15540218943360304, 'fraction_numerical': 0.00047596382674916705, 'mean_word_length': 1.9391608391608393, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 2, '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': '2517233', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1361, 'n_words': 209}