<commit_before><commit_msg>Added a simple, fallback class loader.<commit_after><?php

/**
 * This file is part of the Polyglot package.
 *
 * For the full copyright and license information, please view the LICENSE file
 * that was distributed along with this source code.
 *
 * @license https://github.com/unwiredbrain/polyglot/blob/master/LICENSE MIT License
 */

/**
 * Simple autoloader that follow the PHP Standards Recommendation #0 (PSR-0)
 * Code inspired from both the SplClassLoader RFC and the Geocoder autoload.
 *
 * @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
 * @see https://wiki.php.net/rfc/splclassloader#example_of_simplest_implementation
 * @see https://github.com/willdurand/Geocoder/blob/master/src/autoload.php
 */
spl_autoload_register(function($className) {
    $className = ltrim($className, '\\');

    if (0 != strpos($className, 'Polyglot')) {
        return false;
    }

    $fileName = '';
    $namespace = '';

    if ($lastNsPos = strrpos($className, '\\')) {
        $namespace = substr($className, 0, $lastNsPos);
        $className = substr($className, $lastNsPos + 1);
        $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
    }

    $fileName = __DIR__ . DIRECTORY_SEPARATOR . $fileName . $className . '.php';

    if (is_readable($fileName) && is_file($filename)) {
        require $fileName;
        return true;
    }

    return false;
});

{'fraction_non_alphanumeric': 0.1383344803854095, 'fraction_numerical': 0.0041293874741913286, 'mean_word_length': 3.4876543209876543, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '6226611', 'n_tokens_mistral': 468, 'n_tokens_neox': 453, 'n_words': 107}