<commit_before>'use strict';

var _ = require('lodash'),
    Path = require('path');

function node(tree, parts, item) {
    var part = parts.shift();

    if (!part) return tree.push(item);

    tree[part] = tree[part] || [];
    return node(tree[part], parts, item);
}

module.exports = function transform(config, done) {
    config.pages = _.reduce(config.sources, function(tree, source) {
        var parts = source.relative.slice(1).split('/').slice(0, -1),
            filebody = Path.basename(source.relative).replace(new RegExp(Path.extname(source.relative) + '$'), '');

        parts.push(filebody);
        node(tree, parts, source.relative);

        return tree;
    }, []);

    done(null, config);
};<commit_msg>fix tip of the tree<commit_after>'use strict';

var _ = require('lodash'),
    Path = require('path');

function node(tree, parts, item) {
    var part = parts.shift();

    if (!parts.length){
        tree[part] = item;
        return;
    }

    tree[part] = tree[part] || [];
    return node(tree[part], parts, item);
}

module.exports = function transform(config, done) {
    config.pages = _.reduce(config.sources, function(tree, source) {
        var parts = source.relative.slice(1).split('/').slice(0, -1),
            filebody = Path.basename(source.relative).replace(new RegExp(Path.extname(source.relative) + '$'), '');

        parts.push(filebody);
        node(tree, parts, source);

        return tree;
    }, []);

    done(null, config);
};
{'fraction_non_alphanumeric': 0.17845117845117844, 'fraction_numerical': 0.00404040404040404, 'mean_word_length': 3.0712328767123287, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6455507', 'n_tokens_mistral': 472, 'n_tokens_neox': 459, 'n_words': 97}