<commit_before>iD.ui.preset = function(context) {
    var event = d3.dispatch('change', 'setTags', 'close'),
        entity,
        tags,
        keys,
        preset,
        formwrap,
        formbuttonwrap;

    function input(d) {
        var i = iD.ui.preset[d.type](d, context)
            .on('close', event.close)
            .on('change', event.change);

        event.on('setTags.' + d.key || d.type, function(tags) {
            i.tags(_.clone(tags));
        });

        if (d.type === 'address') i.entity(entity);

        keys = keys.concat(d.key ? [d.key] : d.keys);

        d3.select(this).call(i);
    }

    function presets(selection) {

        selection.html('');
        keys = [];

        formwrap = selection.append('div');
        draw(formwrap, preset.fields);

        var wrap = selection.append('div')
            .attr('class', 'col12 more-buttons inspector-inner');

        wraplabel = wrap.append('h4');

        wraplabel.append('div').attr('class','icon add-form');
        wraplabel.append('span')
        .attr('class','deemphasize')
        .text('Add additional forms');

       formbuttonwrap = wrap.append('div')
            .attr('class', 'col9 preset-input');

        formbuttonwrap.selectAll('button')
            .data(preset.additional)
            .enter()
            .append('button')
                .attr('class', 'preset-add-field')
                .attr('title', function(d) { return d.label(); })
                .on('click', addForm)
                .append('span')
                    .attr('class', function(d) { return 'icon ' + d.icon; });

        function addForm(d) {
            draw(formwrap, [d]);
            d3.select(this).remove();
            if (!wrap.selectAll('button').node()) wrap.remove();
        }
    }

    function formKey(d) {
        return d.key || String(d.keys);
    }

    function draw(selection, fields) {
        var sections = selection.selectAll('div.preset-section')
            .data(fields, formKey)
            .enter()<commit_msg>Fix global leak<commit_after>iD.ui.preset = function(context) {
    var event = d3.dispatch('change', 'setTags', 'close'),
        entity,
        tags,
        keys,
        preset,
        formwrap,
        formbuttonwrap;

    function input(d) {
        var i = iD.ui.preset[d.type](d, context)
            .on('close', event.close)
            .on('change', event.change);

        event.on('setTags.' + d.key || d.type, function(tags) {
            i.tags(_.clone(tags));
        });

        if (d.type === 'address') i.entity(entity);

        keys = keys.concat(d.key ? [d.key] : d.keys);

        d3.select(this).call(i);
    }

    function presets(selection) {

        selection.html('');
        keys = [];

        formwrap = selection.append('div');
        draw(formwrap, preset.fields);

        var wrap = selection.append('div')
            .attr('class', 'col12 more-buttons inspector-inner');

        var wraplabel = wrap.append('h4');

        wraplabel.append('div')
            .attr('class', 'icon add-form');

        wraplabel.append('span')
            .attr('class', 'deemphasize')
            .text('Add additional forms');

       formbuttonwrap = wrap.append('div')
            .attr('class', 'col9 preset-input');

        formbuttonwrap.selectAll('button')
            .data(preset.additional)
            .enter()
            .append('button')
                .attr('class', 'preset-add-field')
                .attr('title', function(d) { return d.label(); })
                .on('click', addForm)
                .append('span')
                    .attr('class', function(d) { return 'icon ' + d.icon; });

        function addForm(d) {
            draw(formwrap, [d]);
            d3.select(this).remove();
            if (!wrap.selectAll('button').node()) wrap.remove();
        }
    }

    function formKey(d) {
        return d.key || String(d.keys);
    }

    function draw(selection, fields) {
        var sections = selection.selectAll('div.preset-section')
            .data(fields, formKey)
            .enter()
{'fraction_non_alphanumeric': 0.16658524670249145, 'fraction_numerical': 0.003419638495359062, 'mean_word_length': 1.7971311475409837, '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': '6392984', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1209, 'n_words': 217}