<commit_before>var getURLParams = function() {
    var match,
        pl = /\+/g, // Regex for replacing addition symbol with a space
        search = /([^&=]+)=?([^&]*)/g,
        decode = function(s) {
            return decodeURIComponent(s.replace(pl, " "));
        },
        query = window.location.search.substring(1);

    var urlParams = {};
    while ((match = search.exec(query))) {
        var key = decode(match[1]);
        var value = decode(match[2]);
        if (value === "null") {
            value = null;
        } else if (value === "true") {
            value = true;
        } else if (value === "false") {
            value = false;
        }
        // it's possible there are multiple values for things such as labels
        if (_.isUndefined(urlParams[key])) {
            urlParams[key] = value;
        } else {
            // urlParams[key] += "&" + key + "=" + value;
            urlParams[key] += "," + value;
        }
    }
    return urlParams;
};

var ClassifierMainView = React.createClass({
    getInitialState: function() {
        var urlp = getURLParams();
        return {
            updating: true,
            name: urlp.name,
            info: null,
        };
    },
    updateInfo: function(info) {
        this.setState({info: info});
    },
    componentDidMount: function() {
        this.refreshData(this.state.name);
    },
    refreshData: function() {
        this.setState({updating: true});
        this.refs.ajax.sendNewRequest({name: this.state.name});
    },
    render: function() {
        if(!this.state.name) { return <ClassifierList />; }

        var items = [];
        items.push(<AjaxRequest quiet={false} ref={"ajax"} url={"/api/listClassifiers"} onNewResponse={this.updateInfo} />);

        if(this.state.updating) {
            items.push(<div>Updating...</div>);
        }
        var info = this.state.info;
        if (info) {
            items.push(<label>{"Name: "}<span className={"fieldValue"}>{info.name}</span></label>);
            items.push(<label>{"Description: "}<span className={"fieldValue"}>{info.description || <i>NONE</i>}</span></label>);

            items.push(<LabelRandomSentence classifier={this.state.name} refresh={this.refreshData} />);

            items.push(<RecentLabels labels={info.labelEvents} count={10} />);
            //items.push(<pre>{JSON.stringify(this.state.info)}</pre>);
        }

        return <div>{items}</div>;
    }
});

var RecentLabels = React.createClass({
    getInitialState: function() {
        return {tokensById: {}};
    },
    componentDidMount: function() {<commit_msg>include more basic stats about classifier<commit_after>var getURLParams = function() {
    var match,
        pl = /\+/g, // Regex for replacing addition symbol with a space
        search = /([^&=]+)=?([^&]*)/g,
        decode = function(s) {
            return decodeURIComponent(s.replace(pl, " "));
        },
        query = window.location.search.substring(1);

    var urlParams = {};
    while ((match = search.exec(query))) {
        var key = decode(match[1]);
        var value = decode(match[2]);
        if (value === "null") {
            value = null;
        } else if (value === "true") {
            value = true;
        } else if (value === "false") {
            value = false;
        }
        // it's possible there are multiple values for things such as labels
        if (_.isUndefined(urlParams[key])) {
            urlParams[key] = value;
        } else {
            // urlParams[key] += "&" + key + "=" + value;
            urlParams[key] += "," + value;
        }
    }
    return urlParams;
};

var ClassifierMainView = React.createClass({
    getInitialState: function() {
        var urlp = getURLParams();
        return {
            updating: true,
            name: urlp.name,
            info: null,
        };
    },
    updateInfo: function(info) {
        this.setState({info: info});
    },
    componentDidMount: function() {
        this.refreshData(this.state.name);
    },
    refreshData: function() {
        this.setState({updating: true});
        this.refs.ajax.sendNewRequest({name: this.state.name});
    },
    render: function() {
        if(!this.state.name) { return <ClassifierList />; }

        var items = [];
        items.push(<AjaxRequest quiet={false} ref={"ajax"} url={"/api/listClassifiers"} onNewResponse={this.updateInfo} />);

        if(this.state.updating) {
            items.push(<div>Updating...</div>);
        }
        var info = this.state.info;
        if (info) {
            items.push(<label>{"Name: "}<span className={"fieldValue"}>{info.name}</span></label>);
            items.push(<label>{"Description: "}<span className={"fieldValue"}>{info.description || <i>NONE</i>}</span></label>);

            var totalCount = _.size(info.labelEvents);
            var positiveCount = _.size(_.filter(info.labelEvents, function(evt) { return evt.positive; }));
            var negativeCount = totalCount - positiveCount;

            items.push(<label>{"Positive Labels: "}<span className={"fieldValue"}>{positiveCount+"/"+totalCount}</span></label>);
            items.push(<label>{"Negative Labels: "}<span className={"fieldValue"}>{negativeCount+"/"+totalCount}</span></label>);

            items.push(<LabelRandomSentence classifier={this.state.name} refresh={this.refreshData} />);

            items.push(<RecentLabels labels={info.labelEvents} count={10} />);
            //items.push(<pre>{JSON.stringify(this.state.info)}</pre>);
        }

        return <div>{items}</div>;
    }
});

var RecentLabels = React.createClass({
    getInitialState: function() {
        return {tokensById: {}};
    },
    componentDidMount: function() {
{'fraction_non_alphanumeric': 0.17181231466945754, 'fraction_numerical': 0.0017442874585731729, 'mean_word_length': 2.254256526674234, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, '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': '3295024', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1660, 'n_words': 318}