<commit_before>module.exports = function (entities) {
    var res = [];

    if (!entities) { return []; }
    if (typeof entities.length === 'undefined') { entities = [entities]; }

    for (var i = 0; i < entities.length; ++i) {
        var entity = entities[i],
            block = entity.name,
            mods = entity.mods,
            elems = entity.elems;

        res.push({ block: block });

        if (mods) {
            normalizeMods(block, mods);
        }

        if (elems) {
            for (var j = 0; j < elems.length; ++j) {
                var elem = elems[j],
                    elemName = elem.name,
                    elemMods = elem.mods;

                res.push({ block: block, elem: elemName });

                if (elemMods) {
                    normalizeMods(block, elemName, elemMods);
                }
            }
        }
    }

    function normalizeMods(block, elem, mods) {
        var l = arguments.length;

        if (l === 2) {
            mods = elem;
        }

        for (var i = 0; i < mods.length; ++i) {
            var mod = mods[i],
                vals = mod.vals;

            for (var j = 0; j < vals.length; ++j) {
                var resItem = {
                    block: block,
                    modName: mod.name, modVal: vals[i].name
                };

                l === 3 && (resItem.elem = elem);

                res.push(resItem);
            }
        }
    }

    return res;
};<commit_msg>Fixed `normalize` method<commit_after>module.exports = function (entities) {
    var res = [];

    if (!entities) { return []; }
    if (typeof entities.length === 'undefined') { entities = [entities]; }

    for (var i = 0; i < entities.length; ++i) {
        var entity = entities[i],
            block = entity.name,
            mods = entity.mods,
            elems = entity.elems;

        res.push({ block: block });

        if (mods) {
            normalizeMods(block, mods);
        }

        if (elems) {
            for (var j = 0; j < elems.length; ++j) {
                var elem = elems[j],
                    elemName = elem.name,
                    elemMods = elem.mods;

                res.push({ block: block, elem: elemName });

                if (elemMods) {
                    normalizeMods(block, elemName, elemMods);
                }
            }
        }
    }

    function normalizeMods(block, elem, mods) {
        var isElem = arguments.length === 3;

        if (!isElem) {
            mods = elem;
        }

        for (var i = 0; i < mods.length; ++i) {
            var mod = mods[i],
                vals = mod.vals,
                l = vals && vals.length,
                resItem;

            if (l) {
                for (var j = 0; j < l; ++j) {
                    resItem = {
                        block: block,
                        modName: mod.name, modVal: vals[i].name
                    };

                    isElem && (resItem.elem = elem);

                    res.push(resItem);
                }
            } else {
                resItem = {
                    block: block,
                    modName: mod.name, modVal: true
                };

                isElem && (resItem.elem = elem);

                res.push(resItem);
            }
        }
    }

    return res;
};
{'fraction_non_alphanumeric': 0.12567648827420325, 'fraction_numerical': 0.003307276007215875, 'mean_word_length': 1.0741895261845387, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '1019039', 'n_tokens_mistral': 1018, 'n_tokens_neox': 940, 'n_words': 236}