<commit_before>var request = require("request");
var url = require("url");

var foodService = {};

foodService.options = {
	pageSize: 10
};

foodService.apiKey = null;

var buildSearchQuery = function(searchParameters) {
	var searchQueryParts = [];
	for (var field in searchParameters) {

		if (!searchParameters[field]) {
			continue;
		}

		if (field !== "searchTerm") {
			searchQueryParts.push(field + ":");
		}

		searchQueryParts.push(searchParameters[field].replace(/ /g, "+"));
		searchQueryParts.push("+AND+");
	}

	if (searchQueryParts.length > 1) {
		searchQueryParts.remove(searchQueryParts.length - 1);
	}

	return searchQueryParts.join("+");
}

foodService.searchFoodEnforcement = function(searchParameters, page, resultCallback) {
	var endpoint = new Object();
	endpoint.protocol = "https:"
	endpoint.host = "api.fda.gov";
	endpoint.pathname = "/food/enforcement.json";
	endpoint.query = {
		"api_key": foodService.apiKey,
		"search": buildSearchQuery(searchParameters),
		"limit": foodService.options.pageSize,
		"skip": page - 1 * foodService.options.pageSize
	};

	var path = url.format(endpoint);

	request.get(path, function(error, response, body) {
		if (error) {
			resultCallback(error, null);
			return;
		}

		var results = JSON.parse(body);
		resultCallback(null, results);
	});
}

foodService.setApiKey = function(key) {
	foodService.ApiKey = key;
}

module.exports = foodService;<commit_msg>Fixed incorrect method name for deleting array item<commit_after>var request = require("request");
var url = require("url");

var foodService = {};

foodService.options = {
	pageSize: 10
};

foodService.apiKey = null;

var buildSearchQuery = function(searchParameters) {
	var searchQueryParts = [];
	for (var field in searchParameters) {

		if (!searchParameters[field]) {
			continue;
		}

		if (field !== "searchTerm") {
			searchQueryParts.push(field + ":");
		}

		searchQueryParts.push(searchParameters[field].replace(/ /g, "+"));
		searchQueryParts.push("+AND+");
	}

	if (searchQueryParts.length > 1) {
		searchQueryParts.splice(searchQueryParts.length - 1, 1);
	}

	return searchQueryParts.join("+");
}

foodService.searchFoodEnforcement = function(searchParameters, page, resultCallback) {
	var endpoint = new Object();
	endpoint.protocol = "https:"
	endpoint.host = "api.fda.gov";
	endpoint.pathname = "/food/enforcement.json";
	endpoint.query = {
		"api_key": foodService.apiKey,
		"search": buildSearchQuery(searchParameters),
		"limit": foodService.options.pageSize,
		"skip": page - 1 * foodService.options.pageSize
	};

	var path = url.format(endpoint);

	request.get(path, function(error, response, body) {
		if (error) {
			resultCallback(error, null);
			return;
		}

		var results = JSON.parse(body);
		resultCallback(null, results);
	});
}

foodService.setApiKey = function(key) {
	foodService.ApiKey = key;
}

module.exports = foodService;
{'fraction_non_alphanumeric': 0.149704758596735, 'fraction_numerical': 0.0038207711010767626, 'mean_word_length': 4.748502994011976, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 5, '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': '6579080', 'n_tokens_mistral': 997, 'n_tokens_neox': 915, 'n_words': 183}