<commit_before>'use strict';

var cheerio = require('cheerio');

function parseHtml(htmlString){
	var $ = cheerio.load(htmlString);
	if($('.errorTitle').text()) return new Error('Quota limit exceeded, try again later');

	var listItems = $('a').attr('onclick', "trends.PageTracker.analyticsTrackEvent('rising drilldown');").text();
	var barValues = $('td.trends-bar-chart-value-cell').text();
	
	listItems = removeWhiteSpace(listItems.replace(/\r?\n|\r/g, ",").split(','));
	barValues = removeWhiteSpace(barValues.replace(/\r?\n|\r/g, "!").split('!'));

	if(listItems.length === barValues.length){
		return listItems.reduce(function(acc, curr, index){
			acc[curr] = barValues[index];
			return acc;
		}, {});
	}

	return listItems;

}

function removeWhiteSpace(arr){
	return arr.reduce(function(acc, curr){
		if(curr.trim() !== "") acc.push(curr.trim());
		return acc;
	}, []);
}

function parseJSON(htmlString){
	if(htmlString && htmlString.indexOf('errorTitle') !== -1)
		throw new Error('Quota limit exceeded, try again later');
	try {
        var parsedTrends, trendsData = [], google = { 'visualization': { 'Query': { 'setResponse': function(data) { parsedTrends = data; } } } }
        eval(htmlString);
        if(!parsedTrends) {
        	return [];
        }
        if(parsedTrends.table) {
        	for(let i = 1; i < parsedTrends.table.cols.length; i++){
        		trendsData.push({
        			query: parsedTrends.table.cols[i].label,
        			values: []
        		});
        	}
        	for(let j = 0; j < parsedTrends.table.rows.length; j++){
        		var data = parsedTrends.table.rows[j].c, date = data[0].v;
        		for(let k = 1; k < data.length; k++){
        			trendsData[k-1].values.push({
        				date: date.toUTCString(),
        				value: data[k].v
        			})
        		}
        	}
        	return trendsData;
        }
        return [];
    } catch (err) {
    	console.log(err);
        return [];
    }
}

module.exports = {
	parseHtml: parseHtml,
	parseJSON: parseJSON
};<commit_msg>Removed unnecessary quotes around keywords in trends api<commit_after>'use strict';

var cheerio = require('cheerio');

function parseHtml(htmlString){
	var $ = cheerio.load(htmlString);
	if($('.errorTitle').text()) return new Error('Quota limit exceeded, try again later');

	var listItems = $('a').attr('onclick', "trends.PageTracker.analyticsTrackEvent('rising drilldown');").text();
	var barValues = $('td.trends-bar-chart-value-cell').text();
	
	listItems = removeWhiteSpace(listItems.replace(/\r?\n|\r/g, ",").split(','));
	barValues = removeWhiteSpace(barValues.replace(/\r?\n|\r/g, "!").split('!'));

	if(listItems.length === barValues.length){
		return listItems.reduce(function(acc, curr, index){
			acc[curr] = barValues[index];
			return acc;
		}, {});
	}

	return listItems;

}

function removeWhiteSpace(arr){
	return arr.reduce(function(acc, curr){
		if(curr.trim() !== "") acc.push(curr.trim());
		return acc;
	}, []);
}

function parseJSON(htmlString){
	if(htmlString && htmlString.indexOf('errorTitle') !== -1)
		throw new Error('Quota limit exceeded, try again later');
	try {
        var parsedTrends, trendsData = [], google = { 'visualization': { 'Query': { 'setResponse': function(data) { parsedTrends = data; } } } }
        eval(htmlString);
        if(!parsedTrends) {
        	return [];
        }
        if(parsedTrends.table) {
        	for(let i = 1; i < parsedTrends.table.cols.length; i++){
        		trendsData.push({
        			query: parsedTrends.table.cols[i].label,
        			values: []
        		});
        	}
        	for(let j = 0; j < parsedTrends.table.rows.length; j++){
        		var data = parsedTrends.table.rows[j].c, date = data[0].v;
        		for(let k = 1; k < data.length; k++){
        			trendsData[k-1].values.push({
        				date: date.toISOString(),
        				value: data[k].v
        			})
        		}
        	}
        	return trendsData;
        }
        return [];
    } catch (err) {
    	console.log(err);
        return [];
    }
}

module.exports = {
	parseHtml: parseHtml,
	parseJSON: parseJSON
};
{'fraction_non_alphanumeric': 0.17791859614915914, 'fraction_numerical': 0.002924689251767, 'mean_word_length': 2.8070500927643787, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7432242', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1376, 'n_words': 257}