<commit_before><?
class Indie {
    private $data;
    private $obj;


    public function __construct( $data = null ) {
        $data ?: [];
    }

    /**
     * @param array $data
     * @return Indie
     */
    public function import( $data = null ) {
        if ( $data !== null ) {
            $this->data = $this->data?array_merge_recursive( $this->data, $data ):$data;
        }

        return $this;
    }

    /**
     * @param string $indexpath
     * @return Value
     */
    public function key( $indexpath ) {
        $value = $this->parseIndexPath( $indexpath );
        $isExplicit = $this->isIndexPathExplicit( $indexpath );

        if ( !isset( $this->obj[$indexpath] ) ) {
            $this->obj[ $indexpath ] = new Value( $value, $isExplicit );
        }

        return $this->obj[ $indexpath ];
    }

    /**
     * @param string $indexpath
     * @return bool
     */
    public function isValid( $indexpath = null ) {
        if ( $indexpath ) {
            return $this->key( $indexpath )->isValid();
        }

        return count( $this->getErrors() ) ? false : true;
    }

    /**
     * @param string $indexpath
     * @return string
     */
    public function getValue( $indexpath ) {
        return $this->key($indexpath)->getValue();
    }

    /**
     * @return array
     */
    public function getValues() {
        return array_map( function($value) {
            /** @var Value $value */
            return $value->getValue();
        }, $this->obj);
    }


    /**
     * @param string $indexpath
     * @return array
     */
    public function getErrors( $indexpath = null ) {
        if ( $indexpath ) {
            return $this->key( $indexpath )->getErrors();
        }

        $errors = [];
        foreach( $this->obj as $indexpath => $value ) {
            /** @var Value $value */
            $errors[$indexpath] = $value->getErrors();
        }

        return $errors;
    }

    protected function parseIndexPath( $indexpath ) {
        $key = explode('[', $indexpath)[0];
        preg_match_all('/\[([a-z0-9_-]+)\]/i', $indexpath, $matches);
        $indexpath_array = $matches[1];
<commit_msg>Removed empty keys from error dump<commit_after><?
class Indie {
    private $data;
    private $obj;


    public function __construct( $data = null ) {
        $data ?: [];
    }

    /**
     * @param array $data
     * @return Indie
     */
    public function import( $data = null ) {
        if ( $data !== null ) {
            $this->data = $this->data?array_merge_recursive( $this->data, $data ):$data;
        }

        return $this;
    }

    /**
     * @param string $indexpath
     * @return Value
     */
    public function key( $indexpath ) {
        $value = $this->parseIndexPath( $indexpath );
        $isExplicit = $this->isIndexPathExplicit( $indexpath );

        if ( !isset( $this->obj[$indexpath] ) ) {
            $this->obj[ $indexpath ] = new Value( $value, $isExplicit );
        }

        return $this->obj[ $indexpath ];
    }

    /**
     * @param string $indexpath
     * @return bool
     */
    public function isValid( $indexpath = null ) {
        if ( $indexpath ) {
            return $this->key( $indexpath )->isValid();
        }

        return count( $this->getErrors() ) ? false : true;
    }

    /**
     * @param string $indexpath
     * @return string
     */
    public function getValue( $indexpath ) {
        return $this->key($indexpath)->getValue();
    }

    /**
     * @return array
     */
    public function getValues() {
        return array_map( function($value) {
            /** @var Value $value */
            return $value->getValue();
        }, $this->obj);
    }


    /**
     * @param string $indexpath
     * @return array
     */
    public function getErrors( $indexpath = null ) {
        if ( $indexpath ) {
            return $this->key( $indexpath )->getErrors();
        }

        $errors = [];
        foreach( $this->obj as $indexpath => $value ) {
            /** @var Value $value */
            $value_errors = $value->getErrors();
            if ( count($value_errors) ) {
                $errors[$indexpath] = $value->getErrors();
            }
        }

        return $errors;
    }

    protected function parseIndexPath( $indexpath ) {
        $key = explode('[', $indexpath)[0];
        preg_match_all('/\[([a-z0-9_-]+)\]/i', $indexpath, $matches);
        $indexpath_array = $matches[1];

{'fraction_non_alphanumeric': 0.1605132823052679, 'fraction_numerical': 0.0018009905447996398, 'mean_word_length': 1.7943396226415094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '6459119', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1330, 'n_words': 303}