<commit_before>$( function () {

    $(".menu-item").click(function (ev) {
        $('.dropdown-toggle').dropdown('toggle')
    });


    var get_dict = function (key, dict, def) {
        if (key in dict) {
            if (dict[key] != null && dict[key] != undefined) {
                return dict[key]
            }
        }
        return def
    }

    data.sort(function (a,b) {
        return get_dict('title', a, "Untitled").localeCompare(get_dict('title', b, "Untitles"))
    });


    var rm_whitespace = function(item) {
        return item.replace(/^ */, "").replace(/ *$/, "");
    }

    var search_help = "Search examples,<br>title: a title<br>author: <NAME><br>...<br>Search is case in-sensitive."

    var BadSearchTerm = function(error) {
        this.error = error;
    }

    var get_search_terms = function (query) {

        if (query.indexOf(":") === -1 ) {
            return -1
        }

        var splitted_query = query.split(":")

        if (splitted_query.length != 2 || splitted_query[1] === "" ) {
            throw new BadSearchTerm(search_help)
        }
        key = splitted_query[0]
        term = splitted_query[1]
        return [rm_whitespace(key), rm_whitespace(term)]
    }

    var app = $.sammy("#wrap", function() {

        this.get("#/search", function (context) {

            var query = rm_whitespace(this.params['query'].toLowerCase())

            try {
                var search_terms = get_search_terms(query)
            }

            catch (e) {
                var html = e.error;
                $("#main").html(html)
                return false;
            }

            var results = []

            if (search_terms === -1) {
                for (var i =0; i < data.length; i++) {
                    var title = get_dict("title", data[i], 'Untitled')
                    var author = get_dict("author", data[i], 'Unknown')
                    if (title.toLowerCase().indexOf(query) !== -1
                        || author.toLowerCase().indexOf(query) !== -1) {
                        results.push(i)
                    }
                }
            }

            var key = search_terms[0].toLowerCase()
            var query = search_terms[1].toLowerCase()

            if (key === "tag") {
                for (var i =0; i < data.length; i++) {
                    var tags = get_dict("tags", data[i], [])
                    if (tags.indexOf(query) !== -1)
                        results.push(i)
                }
            }

            else {
                for (var i =0; i < data.length; i++) {
                    if (key === "title") {
                        var value = get_dict(key, data[i], 'Untitled')
                    }
                    else if (key === "author") {
                        var value = get_dict(key, data[i], 'Unknown')
                    }
                    else {
                        var value = get_dict(key, data[i], '-1')
                    }

                    if (value.toLowerCase().indexOf(query) != -1) {
                        results.push(i)
                    }
                }
            }

            if (results.length === 0) {
                var html = "No Results"
            }
            else {
                var html = "<ol>"
                for (var i =0; i < results.length; i++) {
                    html +=  "<li><a href='#/" + data[results[i]]['name'] + "'>" +
                        get_dict('title', data[results[i]], "Untitled") +
                        "</a></li>"
                }
                html += "</ol>"
            }
            $("#main").html(html)

            return false;
        });

        this.get("#/all" , function (context) {
            var html = "<ol>"
            for (var i =0; i < data.length; i++) {
                html +=  "<li><a href='#/" + data[i]['name'] + "'>" +
                    get_dict('title', data[i], "Untitled") +
                    "</a></li>"
            }
            html += "</ol>"

            $("#main").html(html)
        });


        this.get('#/(.*)', function (context) {
            var dhash = document.location.hash;
            post_name = dhash.substring(2);
            for (var i =0; i < data.length; i++) {<commit_msg>some if-else errors<commit_after>$( function () {

    $(".menu-item").click(function (ev) {
        $('.dropdown-toggle').dropdown('toggle')
    });

    // like python
    var get_dict = function (key, dict, def) {
        if (key in dict) {
            if (dict[key] != null && dict[key] != undefined) {
                return dict[key]
            }
        }
        return def
    }

    data.sort(function (a,b) {
        return get_dict('title', a, "Untitled").localeCompare(get_dict('title', b, "Untitles"))
    });


    var rm_whitespace = function(item) {
        return item.replace(/^ */, "").replace(/ *$/, "");
    }

    var search_help = "Search examples,<br>title: a title<br>author: <NAME><br>...<br>Search is case in-sensitive."

    var BadSearchTerm = function(error) {
        this.error = error;
    }

    var get_search_terms = function (query) {

        if (query.indexOf(":") === -1 ) {
            return -1
        }

        var splitted_query = query.split(":")

        if (splitted_query.length != 2 || splitted_query[1] === "" ) {
            throw new BadSearchTerm(search_help)
        }
        key = splitted_query[0]
        term = splitted_query[1]
        return [rm_whitespace(key), rm_whitespace(term)]
    }

    var app = $.sammy("#wrap", function() {

        this.get("#/search", function (context) {

            var query = rm_whitespace(this.params['query'].toLowerCase())

            try {
                var search_terms = get_search_terms(query)
            }

            catch (e) {
                var html = e.error;
                $("#main").html(html)
                return false;
            }

            var results = []

            if (search_terms === -1) {
                for (var i =0; i < data.length; i++) {
                    var title = get_dict("title", data[i], 'Untitled')
                    var author = get_dict("author", data[i], 'Unknown')
                    if (title.toLowerCase().indexOf(query) !== -1
                        || author.toLowerCase().indexOf(query) !== -1) {
                        results.push(i)
                    }
                }

            }


            else {
                var key = search_terms[0].toLowerCase()
                var query = search_terms[1].toLowerCase()

                if (key === "tag") {
                    for (var i =0; i < data.length; i++) {
                        var tags = get_dict("tags", data[i], [])
                        if (tags.indexOf(query) !== -1)
                            results.push(i)
                    }
                }

                else {
                    for (var i =0; i < data.length; i++) {
                        if (key === "title") {
                            var value = get_dict(key, data[i], 'Untitled')
                        }
                        else if (key === "author") {
                            var value = get_dict(key, data[i], 'Unknown')
                        }
                        else {
                            var value = get_dict(key, data[i], '-1')
                        }

                        if (value.toLowerCase().indexOf(query) != -1) {
                            results.push(i)
                        }
                    }
                }
            }

            if (results.length === 0) {
                var html = "No Results"
            }

            else {
                var html = "<ol>"
                for (var i =0; i < results.length; i++) {
                    html +=  "<li><a href='#/" + data[results[i]]['name'] + "'>" +
                        get_dict('title', data[results[i]], "Untitled") +
                        "</a></li>"
                }
                html += "</ol>"
            }

            $("#main").html(html)

            return false;
        });

        this.get("#/all" , function (context) {
            var html = "<ol>"
            for (var i =0; i < data.length; i++) {
                html +=  "<li><a href='#/" + data[i]['name'] + "'>" +
                    get_dict('title', data[i], "Untitled") +
                    "</a></li>"
            }
            html += "</ol>"

            $("#main").html(html)
        });


        this.get('#/(.*)', function (context) {
            var dhash = document.location.hash;
            post_name = dhash.substring(2);
            for (var i =0; i < data.length; i++) {
{'fraction_non_alphanumeric': 0.1570819407629365, 'fraction_numerical': 0.005070877031231992, 'mean_word_length': 1.1711283462596949, 'pattern_counts': {'":': 4, '<': 49, '<?xml version=': 0, '>': 37, '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': '1247268', 'n_tokens_mistral': 2512, 'n_tokens_neox': 2383, 'n_words': 521}