<commit_before>'use strict';

var _ = require('underscore');
var request = require('request');
var cheerio = require('cheerio');
var async = require('async');

var yelp = require("yelp").createClient({
  consumer_key: "E-Q0xyoYv-4_7B9oVw_e_w", 
  consumer_secret: "<KEY>",
  token: "<KEY>",
  token_secret: "<KEY>"
});

function getRestaurants(lat, lng, term, cb) {
    var searchString = lat+","+lng;
    var distance = 50000; //distance in meters
    yelp.search({term: term, ll:searchString, radius_filter: distance},function (err, data) {
        var fns = [];
        if (!data.businesses) {
            cb(new Error('Wrong Lat and Long in getRestaurants'), null);
            return;
        }
        _.each(data.businesses, function (elem) {
            fns.push(function (done) {
                getRestaurantPrice(elem.url, function (err, price) {
                    elem.price = price;
                    done();
                });
            });
        });
        async.parallel(fns, function (err) {
            cb(data.businesses);
        });
    });
}

function getAmount(numDollarSign) {
    if (numDollarSign === 1) {
        return 8;
    } else if (numDollarSign === 2) {
        return 20;
    } else if (numDollarSign === 3) {
        return 45;
    } else {
        return 60;
    }
}

function getRestaurantPrice(url, cb) {
    var filterClass = 'span.business-attribute.price-range';
    request(url, function (err, resp, body) {
        var $ = cheerio.load(body);
        var dollarSign = $(filterClass).html().length;
        var price = getAmount(dollarSign);
        cb(err, price);
    });
    // Passes average price for the restaurant with given restaurant id(rest_id) to the callback(cb) 
}

function getRec(lat, lng, term, cb) {
    getRestaurants(lat, lng, term, function (err, data) {
        if (!data.businesses) {
            cb(new Error('Wrong lat and long in getRec'), null);
            return;
        }
        var sorted = _.sortBy(data.businesses, function (elem) {<commit_msg>Better Safety check<commit_after>'use strict';

var _ = require('underscore');
var request = require('request');
var cheerio = require('cheerio');
var async = require('async');

var yelp = require("yelp").createClient({
  consumer_key: "E-Q0xyoYv-4_7B9oVw_e_w", 
  consumer_secret: "<KEY>",
  token: "<KEY>",
  token_secret: "<KEY>"
});

function getRestaurants(lat, lng, term, cb) {
    var searchString = lat+","+lng;
    var distance = 50000; //distance in meters
    yelp.search({term: term, ll:searchString, radius_filter: distance},function (err, data) {
        var fns = [];
        if (!data || !data.businesses) {
            cb(new Error('Wrong Lat and Long in getRestaurants'), null);
            return;
        }
        _.each(data.businesses, function (elem) {
            fns.push(function (done) {
                getRestaurantPrice(elem.url, function (err, price) {
                    elem.price = price;
                    done();
                });
            });
        });
        async.parallel(fns, function (err) {
            cb(data.businesses);
        });
    });
}

function getAmount(numDollarSign) {
    if (numDollarSign === 1) {
        return 8;
    } else if (numDollarSign === 2) {
        return 20;
    } else if (numDollarSign === 3) {
        return 45;
    } else {
        return 60;
    }
}

function getRestaurantPrice(url, cb) {
    var filterClass = 'span.business-attribute.price-range';
    request(url, function (err, resp, body) {
        var $ = cheerio.load(body);
        var dollarSign = $(filterClass).html().length;
        var price = getAmount(dollarSign);
        cb(err, price);
    });
    // Passes average price for the restaurant with given restaurant id(rest_id) to the callback(cb) 
}

function getRec(lat, lng, term, cb) {
    getRestaurants(lat, lng, term, function (err, data) {
        if (!data || !data.businesses) {
            cb(new Error('Wrong lat and long in getRec'), null);
            return;
        }
        var sorted = _.sortBy(data.businesses, function (elem) {
{'fraction_non_alphanumeric': 0.14096916299559473, 'fraction_numerical': 0.00930004894762604, 'mean_word_length': 2.336326530612245, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '612056', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1258, 'n_words': 318}