<commit_before>// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

function get_label_tag(hxl) {
    if (chart_label_tag && hxl.hasColumn(chart_label_tag)) {
        return chart_label_tag;
    } else {
        // FIXME - just defaulting to first tag for now
        return hxl.columns[0].tag;
    }
}

function get_value_tag(hxl) {
    if (chart_value_tag && hxl.hasColumn(chart_value_tag)) {
        return chart_value_tag;
    } else {
        for (i in hxl.columns) {
            if (/_num$/.test(hxl.columns[i].tag)) {
                return hxl.columns[i].tag;
            }
        }
        alert("No _num tag available for charting.");
    }
}

// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {

    $.get(csv_url, function(csvString) {
        var rawData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.castToScalar});
        var hxlData = new HXLDataset(rawData);
        var label_tag = get_label_tag(hxlData);
        var value_tag = get_value_tag(hxlData);

        var chartData = [[label_tag, value_tag]];
        var iterator = hxlData.iterator();
        while (row = iterator.next()) {
            var label = row.get(label_tag);
            var value = row.get(value_tag);
            if (!isNaN(value)) {
                chartData.push([label, 0 + value]);
            }<commit_msg>Kludged to use new #meta+count tag.<commit_after>// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

function get_label_tag(hxl) {
    if (chart_label_tag && hxl.hasColumn(chart_label_tag)) {
        return chart_label_tag;
    } else {
        // FIXME - just defaulting to first tag for now
        return hxl.columns[0].tag;
    }
}

function get_value_tag(hxl) {
    if (chart_value_tag && hxl.hasColumn(chart_value_tag)) {
        return chart_value_tag;
    } else {
        for (i in hxl.columns) {
            if (hxl.columns[i].tag == '#meta+count' || /_num$/.test(hxl.columns[i].tag)) {
                return hxl.columns[i].tag;
            }
        }
        alert("No _num tag available for charting.");
    }
}

// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {

    $.get(csv_url, function(csvString) {
        var rawData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.castToScalar});
        var hxlData = new HXLDataset(rawData);
        var label_tag = get_label_tag(hxlData);
        var value_tag = get_value_tag(hxlData);

        var chartData = [[label_tag, value_tag]];
        var iterator = hxlData.iterator();
        while (row = iterator.next()) {
            var label = row.get(label_tag);
            var value = row.get(value_tag);
            if (!isNaN(value)) {
                chartData.push([label, 0 + value]);
            }
{'fraction_non_alphanumeric': 0.12426402231174466, 'fraction_numerical': 0.002479082739386427, 'mean_word_length': 2.4972914409534126, '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': '7307273', 'n_tokens_mistral': 1020, 'n_tokens_neox': 1009, 'n_words': 255}