<commit_before><?php

namespace Reactor\Application;

use Reactor\ServiceContainer\ServiceContainerConfigurator;
use Reactor\ServiceContainer\ServiceContainer;

class Module extends ServiceContainer {

    protected $dir = null;
    protected $name;
    protected $path;

    public function __construct($name = '', $data = array()) {
        $this->path = $this->name = $name;
        $this->data = $data;
    }

    public function getModulePath() {
        return $this->path;
    }

    public function init($container = null) {
        if ($container !== null) {
            $this->setParent($container);
            $this->path = $this->parent->getModulePath().'/'.$this->name;
        }
        $configurator = new ModuleConfigurator($this);
        $config_file = $this->getDir().'config.json';
        if (is_file($config_file)) {
            $config_loader = new ConfigurationReaderJSON();
            $config = $config_loader->load($config_file);
            $configurator->load($config);
        }
        return $configurator;
    }

    public function loadModule($name, $module_class) {
        $data = array();
        if ($this->has($name)) {
            $existing_data = $this->get($name);
            if (is_array($existing_data)) {
                $data = $existing_data;
            }
        }
        $module = new $module_class($name, $data);
        $container->set($name, $this);
        $module->init($this);
        return $module;
    }

    public function getDir() {
        if ($this->dir === null) {
            $ref = new \ReflectionClass($this);
            $this->dir = dirname($ref->getFileName()).'/';
        }
        return $this->dir;
    }

    public function getName() {
        return $this->name;
    }
}<commit_msg>Fixed loadModule<commit_after><?php

namespace Reactor\Application;

use Reactor\ServiceContainer\ServiceContainerConfigurator;
use Reactor\ServiceContainer\ServiceContainer;

class Module extends ServiceContainer {

    protected $dir = null;
    protected $name;
    protected $path;

    public function __construct($name = '', $data = array()) {
        $this->path = $this->name = $name;
        $this->data = $data;
    }

    public function getModulePath() {
        return $this->path;
    }

    public function init($container = null) {
        if ($container !== null) {
            $this->setParent($container);
            $this->path = $this->parent->getModulePath().'/'.$this->name;
        }
        $configurator = new ModuleConfigurator($this);
        $config_file = $this->getDir().'config.json';
        if (is_file($config_file)) {
            $config_loader = new ConfigurationReaderJSON();
            $config = $config_loader->load($config_file);
            $configurator->load($config);
        }
        return $configurator;
    }

    public function loadModule($name, $module_class) {
        $data = array();
        if ($this->has($name)) {
            $existing_data = $this->get($name);
            if (is_array($existing_data)) {
                $data = $existing_data;
            }
        }
        $module = new $module_class($name, $data);
        $this->set($name, $module);
        $module->init($this);
        return $module;
    }

    public function getDir() {
        if ($this->dir === null) {
            $ref = new \ReflectionClass($this);
            $this->dir = dirname($ref->getFileName()).'/';
        }
        return $this->dir;
    }

    public function getName() {
        return $this->name;
    }
}
{'fraction_non_alphanumeric': 0.15087918321043675, 'fraction_numerical': 0.0, 'mean_word_length': 2.1947463768115942, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '6061674', 'n_tokens_mistral': 1011, 'n_tokens_neox': 993, 'n_words': 199}