<commit_before>function ddg_spice_congress(api_result) {

    if (api_result.status != "OK" || api_result.results.length == 0) return;

    var stateCodes = {
        "AL": "Alabama",
        "AK": "Alaska",
        "AZ": "Arizona",
        "AR": "Arkansas",
        "CA": "California",
        "CO": "Colorado",
        "CT": "Connecticut",
        "DE": "Delaware",
        "FL": "Florida",
        "GA": "Georgia",
        "HI": "Hawaii",
        "ID": "Idaho",
        "IL": "Illinois",
        "IN": "Indiana",
        "IA": "Iowa",
        "KS": "Kansas",
        "KY": "Kentucky",
        "LA": "Louisiana",
        "ME": "Maine",
        "MD": "Maryland",
        "MA": "Massachusetts",
        "MI": "Michigan",
        "MN": "Minnesota",
        "MS": "Mississippi",
        "MO": "Missouri",
        "MT": "Montana",
        "NE": "Nebraska",
        "NV": "Nevada",
        "NH": "New Hampshire",
        "NJ": "New Jersey",
        "NM": "New Mexico",
        "NY": "New York",
        "NC": "North Carolina",
        "ND": "North Dakota",
        "OH": "Ohio",
        "OK": "Oklahoma",
        "OR": "Oregon",
        "PW": "Palau",
        "PA": "Pennsylvania",
        "PR": "Puerto Rico",
        "RI": "Rhode Island",
        "SC": "South Carolina",
        "SD": "South Dakota",
        "TN": "Tennessee",
        "TX": "Texas",
        "UT": "Utah",
        "VT": "Vermont",
        "VA": "Virginia",
        "WA": "Washington",
        "WV": "West Virginia",
        "WI": "Wisconsin",
        "WY": "Wyoming"
    };
    
    var state   = api_result.results[0].state;
    var chamber = api_result.results[0].chamber;

    Spice.render({
        data             : api_result.results[0],
        header1          : 'Members of the ' + state + ' ' + chamber,
        source_url       : "http://topics.nytimes.com/top/reference/timestopics/"
                            + "organizations/c/congress/index.html",
        source_name      : 'The New York Times',
        template_normal  : 'congress',
        force_big_header : true,
    });
}    


/*******************************
  Handlebars helpers
  *******************************/

// Creates a full name for a given representative
Handlebars.registerHelper ('get_name', function() {
    var name = this.first_name + ' ' + this.middle_name + ' ' + this.last_name;
    return name.replace(/\s+/, " "); //in case no middle name
});

// Returns vote percentage
Handlebars.registerHelper ('votes_pct', function() {
    var pct = parseFloat(this.votes_with_party_pct).toFixed(0);
    return pct + "%";
});<commit_msg>fix get_name congress fn for null middle names<commit_after>function ddg_spice_congress(api_result) {

    if (api_result.status != "OK" || api_result.results.length == 0) return;

    var stateCodes = {
        "AL": "Alabama",
        "AK": "Alaska",
        "AZ": "Arizona",
        "AR": "Arkansas",
        "CA": "California",
        "CO": "Colorado",
        "CT": "Connecticut",
        "DE": "Delaware",
        "FL": "Florida",
        "GA": "Georgia",
        "HI": "Hawaii",
        "ID": "Idaho",
        "IL": "Illinois",
        "IN": "Indiana",
        "IA": "Iowa",
        "KS": "Kansas",
        "KY": "Kentucky",
        "LA": "Louisiana",
        "ME": "Maine",
        "MD": "Maryland",
        "MA": "Massachusetts",
        "MI": "Michigan",
        "MN": "Minnesota",
        "MS": "Mississippi",
        "MO": "Missouri",
        "MT": "Montana",
        "NE": "Nebraska",
        "NV": "Nevada",
        "NH": "New Hampshire",
        "NJ": "New Jersey",
        "NM": "New Mexico",
        "NY": "New York",
        "NC": "North Carolina",
        "ND": "North Dakota",
        "OH": "Ohio",
        "OK": "Oklahoma",
        "OR": "Oregon",
        "PW": "Palau",
        "PA": "Pennsylvania",
        "PR": "Puerto Rico",
        "RI": "Rhode Island",
        "SC": "South Carolina",
        "SD": "South Dakota",
        "TN": "Tennessee",
        "TX": "Texas",
        "UT": "Utah",
        "VT": "Vermont",
        "VA": "Virginia",
        "WA": "Washington",
        "WV": "West Virginia",
        "WI": "Wisconsin",
        "WY": "Wyoming"
    };
    
    var state   = api_result.results[0].state;
    var chamber = api_result.results[0].chamber;

    Spice.render({
        data             : api_result.results[0],
        header1          : 'Members of the ' + state + ' ' + chamber,
        source_url       : "http://topics.nytimes.com/top/reference/timestopics/"
                            + "organizations/c/congress/index.html",
        source_name      : 'The New York Times',
        template_normal  : 'congress',
        force_big_header : true,
    });
}    


/*******************************
  Handlebars helpers
  *******************************/

// Creates a full name for a given representative
Handlebars.registerHelper ('get_name', function() {
    return this.first_name + ' '
            + (this.middle_name ? this.middle_name + ' ' : '')
            + this.last_name;
});

// Returns vote percentage
Handlebars.registerHelper ('votes_pct', function() {
    var pct = parseFloat(this.votes_with_party_pct).toFixed(0);
    return pct + "%";
});
{'fraction_non_alphanumeric': 0.20161756210283074, 'fraction_numerical': 0.002310803004043905, 'mean_word_length': 1.978211009174312, 'pattern_counts': {'":': 104, '<': 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': '224651', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1683, 'n_words': 376}