<commit_before>/*global view, VIS, set_view, topic_hash, utils, d3 */
"use strict";

view.topic = function (p) {
    var div = d3.select("div#topic_view");

    // heading information
    // -------------------

    div.select("h2#topic_header")
        .text(view.topic.label(p.t,
                    utils.shorten(p.words, VIS.overview_words)));

    // (later: nearby topics by J-S div or cor on log probs)
};

view.topic.remark = function (p) {
    d3.select("#topic_view p#topic_remark")
        .text("α = " + VIS.float_format(p.alpha)
                + "; "
                + VIS.percent_format(p.col_sum / p.total_tokens)
                + " of corpus.");
};

view.topic.words = function (words) {
    var trs_w;

    if (view.updating()) {
        return;
    }

    trs_w = d3.select("table#topic_words tbody")
        .selectAll("tr")
        .data(words);

    trs_w.enter().append("tr");
    trs_w.exit().remove();

    trs_w.on("click", function (w) {
        set_view("/word/" + w.word);
    });

    // clear rows
    trs_w.selectAll("td").remove();

    trs_w.append("td").append("a")
        .attr("href", function (w) {
            return "#/word/" + w.word;
        })
        .text(function (w) { return w.word; });

    view.append_weight_tds(trs_w, function (w) {
        return w.weight / words[0].weight;
    });

};

view.topic.docs = function (p) {
    var header_text, trs_d,
        docs = p.docs;

    if (p.year !== undefined) {
        header_text = " in " + p.year;

        // the clear-selected-year button
        d3.select("#topic_year_clear")
            .classed("disabled", false)
            .on("click", function () {
                d3.select(".selected_year").classed("selected_year", false);
                view.updating(true);
                set_view(topic_hash(p.t));
            })
            .classed("hidden", false);

    } else {
        header_text = "";
        d3.select("#topic_year_clear")
            .classed("disabled", true);
    }


    d3.selectAll("#topic_docs span.topic_year")
        .text(header_text);

    if (docs === undefined || docs.length === 0) {
        d3.selectAll("#topic_docs .none")
            .classed("hidden", false);
        d3.select("#topic_docs table")
            .classed("hidden", true);
        return true;
    }
    d3.selectAll("#topic_docs .none")
        .classed("hidden", true);
    d3.select("#topic_docs table")
        .classed("hidden", false);

    trs_d = d3.select("#topic_docs tbody")
        .selectAll("tr")
        .data(docs);

    trs_d.enter().append("tr");
    trs_d.exit().remove();

    // clear rows
    trs_d.selectAll("td").remove();

    trs_d
        .append("td")
        .classed("special_issue", function (d, j) {
            return !!p.specials[j];
        })
        .append("a")
        .html(function (d, j) {
            return p.citations[j];
        });

    trs_d.on("click", function (d) {
        set_view("/doc/" + d.doc);
    });

    view.append_weight_tds(trs_d, function (d) { return d.frac; });

    trs_d.append("td")
        .classed("td-right", true)
        .text(function (d) {
            return VIS.percent_format(d.frac);
        });

    trs_d.append("td")
        .classed("td-right", true)
        .text(function (d) {
            return d.weight;
        });
};

view.topic.yearly = function (p) {
    if (!view.updating()) {<commit_msg>respect special setting in topic view<commit_after>/*global view, VIS, set_view, topic_hash, utils, d3 */
"use strict";

view.topic = function (p) {
    var div = d3.select("div#topic_view");

    // heading information
    // -------------------

    div.select("h2#topic_header")
        .text(view.topic.label(p.t,
                    utils.shorten(p.words, VIS.overview_words)));

    // (later: nearby topics by J-S div or cor on log probs)
};

view.topic.remark = function (p) {
    d3.select("#topic_view p#topic_remark")
        .text("α = " + VIS.float_format(p.alpha)
                + "; "
                + VIS.percent_format(p.col_sum / p.total_tokens)
                + " of corpus.");
};

view.topic.words = function (words) {
    var trs_w;

    if (view.updating()) {
        return;
    }

    trs_w = d3.select("table#topic_words tbody")
        .selectAll("tr")
        .data(words);

    trs_w.enter().append("tr");
    trs_w.exit().remove();

    trs_w.on("click", function (w) {
        set_view("/word/" + w.word);
    });

    // clear rows
    trs_w.selectAll("td").remove();

    trs_w.append("td").append("a")
        .attr("href", function (w) {
            return "#/word/" + w.word;
        })
        .text(function (w) { return w.word; });

    view.append_weight_tds(trs_w, function (w) {
        return w.weight / words[0].weight;
    });

};

view.topic.docs = function (p) {
    var header_text, trs_d,
        docs = p.docs;

    if (p.year !== undefined) {
        header_text = " in " + p.year;

        // the clear-selected-year button
        d3.select("#topic_year_clear")
            .classed("disabled", false)
            .on("click", function () {
                d3.select(".selected_year").classed("selected_year", false);
                view.updating(true);
                set_view(topic_hash(p.t));
            })
            .classed("hidden", false);

    } else {
        header_text = "";
        d3.select("#topic_year_clear")
            .classed("disabled", true);
    }


    d3.selectAll("#topic_docs span.topic_year")
        .text(header_text);

    if (docs === undefined || docs.length === 0) {
        d3.selectAll("#topic_docs .none")
            .classed("hidden", false);
        d3.select("#topic_docs table")
            .classed("hidden", true);
        return true;
    }
    d3.selectAll("#topic_docs .none")
        .classed("hidden", true);
    d3.select("#topic_docs table")
        .classed("hidden", false);

    trs_d = d3.select("#topic_docs tbody")
        .selectAll("tr")
        .data(docs);

    trs_d.enter().append("tr");
    trs_d.exit().remove();

    // clear rows
    trs_d.selectAll("td").remove();

    trs_d
        .append("td")
        .classed(VIS.special_issue_class, function (d, j) {
            return !!p.specials[j];
        })
        .append("a")
        .html(function (d, j) {
            return p.citations[j];
        });

    trs_d.on("click", function (d) {
        set_view("/doc/" + d.doc);
    });

    view.append_weight_tds(trs_d, function (d) { return d.frac; });

    trs_d.append("td")
        .classed("td-right", true)
        .text(function (d) {
            return VIS.percent_format(d.frac);
        });

    trs_d.append("td")
        .classed("td-right", true)
        .text(function (d) {
            return d.weight;
        });
};

view.topic.yearly = function (p) {
    if (!view.updating()) {
{'fraction_non_alphanumeric': 0.17903225806451614, 'fraction_numerical': 0.00469208211143695, 'mean_word_length': 1.9013185878349639, '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': '1155143', 'n_tokens_mistral': 2352, 'n_tokens_neox': 2277, 'n_words': 395}