<commit_before>//IMPORTS
var Twit = require("twit");
var timer = require("timer");
var mongodb = require("mongodb");
var Geode =require('geode');
var conf = require('./config');
var util = require('util')
var io = require('socket.io').listen(conf.sockets.port-1); // temp for test


module.exports = function(con, bd, twit) {

   // Twitter credentials
   var T = new Twit(twit["watchFireZar"]);

   // Twitter rates
   var time = 15000*60, maxRate = 180, pendingRequests;

   // Tweet class definition
   function Tweet(user, text, coordinates) {
      this.user = user;
      this.text = text;
      this.coordinates = coordinates;
   }

   // City properties
   function City(id, area, coordinates, countryCode) {
      this.id = id;
      this.coordinates = coordinates;
      this.noise = 0;
      this.area = area;
      this.tweets = [];
      this.countryCode = countryCode;
   }

   // Extract city names from hotspots
   function parseHotSpots(cities, hotspots, callback) {
      var geo = new Geode('watchFire', {language: 'en', country : 'US'});
      var p, name, code, pending = hotspots.length;
      for (var i in hotspots) {
         p = hotspots[i];
         geo.findNearby({lat:p.coordinates.coordinates[1], lng:p.coordinates.coordinates[0]}, function(err, results) {
            if (!err && results.geonames) {
               name = results.geonames[0].name;
               code = results.geonames[0].countryCode;
               cities[name] = new City(p._id, round(p.coordinates.coordinates), p.coordinates, code);
            }
            if (pending--) {
               callback(cities);
            }
         });
      }
   }

   // Open twitter stream listening for all cities with hotspots
   function openTwitterStreams(cities) {

      // Define watch symbols to search on twitter 
      var watchSymbols = [], tweet, keyword;
      for (var city in cities) {
         if (cities[city].countryCode in conf.keywords) {
            keyword = conf.keywords[cities[city].countryCode]+" "+city;
         } else {
            keyword = "fire "+city;
         }

         // Query and future regexp for streaming
         watchSymbols.push(keyword);
         cities[city].regexp = new RegExp(city, "gi");
<commit_msg>fixed if bug<commit_after>//IMPORTS
var Twit = require("twit");
var timer = require("timer");
var mongodb = require("mongodb");
var Geode =require('geode');
var conf = require('./config');
var util = require('util')
var io = require('socket.io').listen(conf.sockets.port-1); // temp for test


module.exports = function(con, bd, twit) {

   // Twitter credentials
   var T = new Twit(twit["watchFireZar"]);

   // Twitter rates
   var time = 15000*60, maxRate = 180, pendingRequests;

   // Tweet class definition
   function Tweet(user, text, coordinates) {
      this.user = user;
      this.text = text;
      this.coordinates = coordinates;
   }

   // City properties
   function City(id, area, coordinates, countryCode) {
      this.id = id;
      this.coordinates = coordinates;
      this.noise = 0;
      this.area = area;
      this.tweets = [];
      this.countryCode = countryCode;
   }

   // Extract city names from hotspots
   function parseHotSpots(cities, hotspots, callback) {
      var geo = new Geode('watchFire', {language: 'en', country : 'US'});
      var p, name, code, pending = hotspots.length;
      for (var i in hotspots) {
         p = hotspots[i];
         geo.findNearby({lat:p.coordinates.coordinates[1], lng:p.coordinates.coordinates[0]}, function(err, results) {
            if (!err && results.geonames) {
               name = results.geonames[0].name;
               code = results.geonames[0].countryCode;
               cities[name] = new City(p._id, round(p.coordinates.coordinates), p.coordinates, code);
            }
            pending--;
            if (pending == 0) {
               callback(cities);
            }
         });
      }
   }

   // Open twitter stream listening for all cities with hotspots
   function openTwitterStreams(cities) {

      // Define watch symbols to search on twitter 
      var watchSymbols = [], tweet, keyword;
      for (var city in cities) {
         if (cities[city].countryCode in conf.keywords) {
            keyword = conf.keywords[cities[city].countryCode]+" "+city;
         } else {
            keyword = "fire "+city;
         }

         // Query and future regexp for streaming
         watchSymbols.push(keyword);
         cities[city].regexp = new RegExp(city, "gi");

{'fraction_non_alphanumeric': 0.13029966703662596, 'fraction_numerical': 0.00732519422863485, 'mean_word_length': 2.3626865671641792, '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': '302193', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1321, 'n_words': 350}