<commit_before><?php
/**
 * Bootstrapping functions, essential and needed for Anax to work together with some common helpers. 
 *
 */

/**
 * Default exception handler.
 *
 */
set_exception_handler ( function ($exception) {
  echo "Anax: Uncaught exception: <p>" . $exception->getMessage() . "</p><pre>" . $exception->getTraceAsString(), "</pre>";
});



/**
 * Autoloader for classes.
 *
 */
spl_autoload_register ( function ($class) {
  $path = ANAX_INSTALL_PATH . "/src/{$class}/{$class}.php";
  if(is_file($path)) {
    require($path);
  }
});



/**
 * PR0 autoloader for classes supporting namespaces, adapted to Anax environment.
 *
 * @link http://www.php-fig.org/psr/psr-0/
 */
spl_autoload_register ( function ($className) {
  $path      = ANAX_INSTALL_PATH . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR;
  $className = ltrim($className, '\\');
  $fileName  = $path;
  $namespace = '';
  if ($lastNsPos = strrpos($className, '\\')) {
    $namespace  = substr($className, 0, $lastNsPos);
    $className  = substr($className, $lastNsPos + 1);
    $fileName  .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
  }
  $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';<commit_msg>Using anonomous functions to setup exception handler and autoloaders<commit_after><?php
/**
 * Bootstrapping functions, essential and needed for Anax to work together with some common helpers. 
 *
 */

/**
 * Default exception handler.
 *
 */
set_exception_handler ( function ($exception) {
  echo "Anax: Uncaught exception: <p>" . $exception->getMessage() . "</p><pre>" . $exception->getTraceAsString(), "</pre>";
});



/**
 * Autoloader for classes using Anax-base names.
 *
 */
spl_autoload_register ( function ($class) {
  $path = ANAX_INSTALL_PATH . "/src/{$class}/{$class}.php";
  if(is_file($path)) {
    require($path);
  }
});



/**
 * PR0 autoloader for classes supporting namespaces, adapted to Anax environment.
 *
 * @link http://www.php-fig.org/psr/psr-0/
 */
spl_autoload_register ( function ($className) {
  $path      = ANAX_INSTALL_PATH . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR;
  $className = ltrim($className, '\\');
  $fileName  = $path;
  $namespace = '';
  if ($lastNsPos = strrpos($className, '\\')) {
    $namespace  = substr($className, 0, $lastNsPos);
    $className  = substr($className, $lastNsPos + 1);
    $fileName  .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
  }
  $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
{'fraction_non_alphanumeric': 0.17338551859099804, 'fraction_numerical': 0.0031311154598825833, 'mean_word_length': 3.9248554913294798, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2710726', 'n_tokens_mistral': 868, 'n_tokens_neox': 852, 'n_words': 184}