<commit_before><?php

namespace Samsui\Generator\Provider\Resource;

use Samsui\Generator\GeneratorInterface;

class Loader
{
    protected $generator;

    public function __construct(GeneratorInterface $generator)
    {
        $this->generator = $generator;
    }

    public function load($resource)
    {
        $lists = array();
        if (is_array($resource) && isset($resource['lists'])) {
            $lists = $resource['lists'];
            unset($resource['lists']);
        }

        if (!is_array($resource)) {
            return $resource;
        } elseif (isset($resource['provider'])) {
            $provider = $resource['provider'];
            $method = $resource['method'];
            $args = isset($resource['args']) ? $resource['args'] : array();
            $result = call_user_func_array(array($this->generator->$provider, $method), $args);
            return $result;
        } elseif (isset($resource['list'])) {
            return $this->generator->math->randomArrayValue($lists[$resource['list']]);
        } else {
            $template = $resource['template'];
            $parts = $resource['parts'];

            $data = array();<commit_msg>improved recursive lists loading<commit_after><?php

namespace Samsui\Generator\Provider\Resource;

use Samsui\Generator\GeneratorInterface;

class Loader
{
    protected $generator;

    public function __construct(GeneratorInterface $generator)
    {
        $this->generator = $generator;
    }

    public function load($resource, $lists = array())
    {
        if (is_array($resource) && isset($resource['lists'])) {
            $lists = array_merge($lists, $resource['lists']);
            unset($resource['lists']);
        }

        if (!is_array($resource)) {
            return $resource;
        } elseif (isset($resource['provider'])) {
            $provider = $resource['provider'];
            $method = $resource['method'];
            $args = isset($resource['args']) ? $resource['args'] : array();
            $result = call_user_func_array(array($this->generator->$provider, $method), $args);
            return $result;
        } elseif (isset($resource['list'])) {
            return $this->generator->math->randomArrayValue($lists[$resource['list']]);
        } else {
            $template = $resource['template'];
            $parts = $resource['parts'];

            $data = array();
{'fraction_non_alphanumeric': 0.16345347862531434, 'fraction_numerical': 0.0, 'mean_word_length': 2.611195158850227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '408739', 'n_tokens_mistral': 619, 'n_tokens_neox': 616, 'n_words': 117}