<commit_before>//	endpoint api to make http requests via flickr
var request = require('request'),
	fs = require('fs'),
	miso = require('../../../modules/miso.util.js'),
	//	Parse out the unwanted parts of the json
	//	typically this would be run on the client
	//	we run this using "request" on  the server, so
	//	no need for the jsonp callback
	jsonParser = function(jsonpData){
		var json, startPos, endPos;
		try {
			startPos = jsonpData.indexOf('({');
			endPos = jsonpData.lastIndexOf('})');
			json = jsonpData
				.substring(startPos+1, endPos+1)
				.split("\n").join("")
				.split("\\'").join("'");

			return JSON.parse(json);
		} catch(ex) {
			console.log("ERROR", ex);
			return "{}";
		}
	},
	//	testing cache
	photoDataCache = JSON.parse(fs.readFileSync('public/testdata/photocache.json', {encoding: 'utf8'}));;

module.exports = function(utils){
	return {
		photos: function(cb, err, args){
			//	TESTING WITH PHOTO CACHE
			if(photoDataCache) {
				cb(photoDataCache);
			} else {
				args = args || {};
				var url = "http://api.flickr.com/services/feeds/photos_public.gne?format=json";
				//	Add parameters
				url += miso.each(args, function(value, key){
					return "&" + key + "=" + value;
				});
				request(url, function (error, response, body) {
					if (!error && response.statusCode == 200) {
						photoDataCache = jsonParser(body);
						cb(photoDataCache);
					} else {
						err(error);
					}
				});
			}
		}
	};
};<commit_msg>Fix API url mapping<commit_after>//	endpoint api to make http requests via flickr
var request = require('request'),
	fs = require('fs'),
	miso = require('../../../modules/miso.util.js'),
	//	Parse out the unwanted parts of the json
	//	typically this would be run on the client
	//	we run this using "request" on  the server, so
	//	no need for the jsonp callback
	jsonParser = function(jsonpData){
		var json, startPos, endPos;
		try {
			startPos = jsonpData.indexOf('({');
			endPos = jsonpData.lastIndexOf('})');
			json = jsonpData
				.substring(startPos+1, endPos+1)
				.split("\n").join("")
				.split("\\'").join("'");

			return JSON.parse(json);
		} catch(ex) {
			console.log("ERROR", ex);
			return "{}";
		}
	},
	//	testing cache
	photoDataCache = JSON.parse(fs.readFileSync('public/testdata/photocache.json', {encoding: 'utf8'}));;

module.exports = function(utils){
	return {
		photos: function(cb, err, args){
			//	TESTING WITH PHOTO CACHE
			if(photoDataCache) {
				cb(photoDataCache);
			} else {
				args = args || {};
				var url = "http://api.flickr.com/services/feeds/photos_public.gne?format=json";
				//	Add parameters
				url += miso.each(args, function(value, key){
					return "&" + key + "=" + value;
				}).join("");
				request(url, function (error, response, body) {
					if (!error && response.statusCode == 200) {
						photoDataCache = jsonParser(body);
						cb(photoDataCache);
					} else {
						err(error);
					}
				});
			}
		}
	};
};
{'fraction_non_alphanumeric': 0.17475398710553106, 'fraction_numerical': 0.0040719375636240245, 'mean_word_length': 3.0438957475994513, 'pattern_counts': {'":': 0, '<': 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': '3844892', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1002, 'n_words': 240}