<commit_before>$(function(){
    var report_template = _.template($('#report-template').html());

    window.removeColumn = function() {
        geoid = $(this).attr('data-val');

        // First item in list
        if (document.location.pathname.indexOf('/' + geoid + ',') > 0) {
            document.location.pathname = document.location.pathname.replace('/' + geoid + ',', '/');
        // Any other item in list
        } else {
            document.location.pathname = document.location.pathname.replace(',' + geoid, '');
        }
    }
    
    window.twistRow = function() {
        var show_child = $(this).is('.closed');
        twistRowHelper($(this), show_child);
        $(this).toggleClass('closed')
        $(this).toggleClass('open');
    }
    
    window.twistRowHelper = function(parent_row, show_me) {
        $.each($('tr[parent=' + $(parent_row).attr('id') + ']'), function(index, value){
            if(show_me){
                $(value).show();
            } else {
                $(value).hide();
            }

            var show_child = false;
            if($(value).is(':visible') && $(value).is('.has-children.open')) {
                show_child = true;
            }

            twistRowHelper(value, show_child);
        });
    }
    
    window.addRelatedState = function() {
        this_geoid = $(this).attr('data-val');
        state_geoid = this_geoid.slice(0,2);
        
        window.location.pathname = window.location.pathname.replace('.html', "," + state_geoid + '.html');
    }

    window.addRelatedCounty = function() {
        this_geoid = $(this).attr('data-val');
        county_geoid = this_geoid.slice(0,5);
        
        window.location.pathname = window.location.pathname.replace('.html', "," + county_geoid + '.html');
    }

    window.apiRequest = function(path, callback, handler) {
        $.ajax(API_URL + path, {
            dataType: "jsonp",
            jsonpCallback: callback,
            success: handler
        });
    }

    window.parseGeoids = function() {
        // Get url without hashbang
        var target = _.last(window.location.pathname.split("/"));

        // Ditch the .html
        target = _.first(target.split("."));

        // Split the list
        geoids = target.split(",");

        return geoids;
    }

    window.downloadData = function(format) {
        var url = "/data/" + window.geoids.join(",") + "." + format;

        if (window.location.hash != "") {
             url += "?tables=" + window.location.hash.substring(1);
        }   

        window.location = url;
    }

    window.loadLabels = function() {
        $("#ajax-loader").show();

        apiRequest("/" + window.DATASET + "_labels.jsonp", "labels_" + window.DATASET, function(labels_data) {
            window.labels_data = labels_data;
            window.geoids = parseGeoids();

            window.tables = _.keys(labels_data["tables"])
            window.tables = _.sortBy(window.tables, function(table) {
                parts = table.match(/([A-Z]+)(\d+)([A-Z]+)?/);
                
                key = parts[1];
                num = parts[2];
                   
                while (num.length < 3) {
                    num = '0' + num;
                }

                key += num;

                if (!_.isUndefined(parts[3])) {
                    key += parts[3];
                }

                return key; 
            });

            _.each(window.tables, function(table) {
                var elem = $('<div id="report-wrapper-' + table + '"></div>');
                $('#reports').append(elem);
            });

            geographies = new Array();

            _.each(geoids, function(geoid) {
                var state = geoid.substring(0, 2);

                apiRequest("/" + state + "/" + geoid + ".jsonp", "geoid_" + geoid, function(geography_data) {<commit_msg>extract table comparator<commit_after>$(function(){
    var report_template = _.template($('#report-template').html());

    window.removeColumn = function() {
        geoid = $(this).attr('data-val');

        // First item in list
        if (document.location.pathname.indexOf('/' + geoid + ',') > 0) {
            document.location.pathname = document.location.pathname.replace('/' + geoid + ',', '/');
        // Any other item in list
        } else {
            document.location.pathname = document.location.pathname.replace(',' + geoid, '');
        }
    }
    
    window.twistRow = function() {
        var show_child = $(this).is('.closed');
        twistRowHelper($(this), show_child);
        $(this).toggleClass('closed')
        $(this).toggleClass('open');
    }
    
    window.twistRowHelper = function(parent_row, show_me) {
        $.each($('tr[parent=' + $(parent_row).attr('id') + ']'), function(index, value){
            if(show_me){
                $(value).show();
            } else {
                $(value).hide();
            }

            var show_child = false;
            if($(value).is(':visible') && $(value).is('.has-children.open')) {
                show_child = true;
            }

            twistRowHelper(value, show_child);
        });
    }
    
    window.addRelatedState = function() {
        this_geoid = $(this).attr('data-val');
        state_geoid = this_geoid.slice(0,2);
        
        window.location.pathname = window.location.pathname.replace('.html', "," + state_geoid + '.html');
    }

    window.addRelatedCounty = function() {
        this_geoid = $(this).attr('data-val');
        county_geoid = this_geoid.slice(0,5);
        
        window.location.pathname = window.location.pathname.replace('.html', "," + county_geoid + '.html');
    }

    window.apiRequest = function(path, callback, handler) {
        $.ajax(API_URL + path, {
            dataType: "jsonp",
            jsonpCallback: callback,
            success: handler
        });
    }

    window.parseGeoids = function() {
        // Get url without hashbang
        var target = _.last(window.location.pathname.split("/"));

        // Ditch the .html
        target = _.first(target.split("."));

        // Split the list
        geoids = target.split(",");

        return geoids;
    }

    window.downloadData = function(format) {
        var url = "/data/" + window.geoids.join(",") + "." + format;

        if (window.location.hash != "") {
             url += "?tables=" + window.location.hash.substring(1);
        }   

        window.location = url;
    }
    window.table_comparator = function(table) {
        parts = table.match(/([A-Z]+)(\d+)([A-Z]+)?/);
        
        key = parts[1];
        num = parts[2];
           
        while (num.length < 3) {
            num = '0' + num;
        }

        key += num;

        if (!_.isUndefined(parts[3])) {
            key += parts[3];
        }

        return key; 
    }
    
    window.loadLabels = function() {
        $("#ajax-loader").show();

        apiRequest("/" + window.DATASET + "_labels.jsonp", "labels_" + window.DATASET, function(labels_data) {
            window.labels_data = labels_data;
            window.geoids = parseGeoids();

            window.tables = _.keys(labels_data["tables"])
            window.tables = _.sortBy(window.tables, window.table_comparator);

            _.each(window.tables, function(table) {
                var elem = $('<div id="report-wrapper-' + table + '"></div>');
                $('#reports').append(elem);
            });

            geographies = new Array();

            _.each(geoids, function(geoid) {
                var state = geoid.substring(0, 2);

                apiRequest("/" + state + "/" + geoid + ".jsonp", "geoid_" + geoid, function(geography_data) {
{'fraction_non_alphanumeric': 0.16850434557011285, 'fraction_numerical': 0.0036321183032818785, 'mean_word_length': 1.7773775216138328, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1521734', 'n_tokens_mistral': 2285, 'n_tokens_neox': 2206, 'n_words': 378}