<commit_before>// nominatim module
if (typeof turbo === "undefined") turbo={};
turbo.nominatim = function() {
  var cache = {};

  var nominatim = {};

  function request(search, callback) {
    // ajax (GET) request to nominatim
    $.ajax("http://nominatim.openstreetmap.org/search"+"?X-Requested-With="+configs.appname, {
      data:{
        format:"json",
        q: search
      },
      success: function(data) {
        // hacky firefox hack :( (it is not properly detecting json from the content-type header)
        if (typeof data == "string") { // if the data is a string, but looks more like a json object
          try {
            data = JSON.parse(data);
          } catch (e) {}
        }
        cache[search] = data;
        callback(undefined,data);
      },
      error: function() {
        var err = "An error occured while contacting the osm search server nominatim.openstreetmap.org :(";
        concole.log(err);
        callback(err,null);
      },
    });
  }

  nominatim.get = function(search, callback) {
    if (cache[search] === undefined)
      request(search,callback);
    else
      callback(undefined,cache[search]);
    return nominatim;
  };

  nominatim.getBest = function(search,filter, callback) {
    // shift parameters if filter is omitted
    if (!callback) { callback = filter; filter=null; }
    nominatim.get(search, function(err, data) {
      if (err) {
        callback(err,null);
        return;
      }
      data = data.filter(filter);
      if (data.length === 0)
        callback("No result found",null)
      else
        callback(err, data[0]);
    });
    return nominatim;
  };

  return nominatim;
};<commit_msg>fix {{nominatimCoords:*}} shortcut / bug in nominatim.getBest<commit_after>// nominatim module
if (typeof turbo === "undefined") turbo={};
turbo.nominatim = function() {
  var cache = {};

  var nominatim = {};

  function request(search, callback) {
    // ajax (GET) request to nominatim
    $.ajax("http://nominatim.openstreetmap.org/search"+"?X-Requested-With="+configs.appname, {
      data:{
        format:"json",
        q: search
      },
      success: function(data) {
        // hacky firefox hack :( (it is not properly detecting json from the content-type header)
        if (typeof data == "string") { // if the data is a string, but looks more like a json object
          try {
            data = JSON.parse(data);
          } catch (e) {}
        }
        cache[search] = data;
        callback(undefined,data);
      },
      error: function() {
        var err = "An error occured while contacting the osm search server nominatim.openstreetmap.org :(";
        concole.log(err);
        callback(err,null);
      },
    });
  }

  nominatim.get = function(search, callback) {
    if (cache[search] === undefined)
      request(search,callback);
    else
      callback(undefined,cache[search]);
    return nominatim;
  };

  nominatim.getBest = function(search,filter, callback) {
    // shift parameters if filter is omitted
    if (!callback) { callback = filter; filter=null; }
    nominatim.get(search, function(err, data) {
      if (err) {
        callback(err,null);
        return;
      }
      if (filter)
        data = data.filter(filter);
      if (data.length === 0)
        callback("No result found",null)
      else
        callback(err, data[0]);
    });
    return nominatim;
  };

  return nominatim;
};
{'fraction_non_alphanumeric': 0.13625730994152047, 'fraction_numerical': 0.0011695906432748538, 'mean_word_length': 2.3837784371909, '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': '3342191', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1019, 'n_words': 267}