<commit_before>/* 
 * asio - js library
 * 
 * requires jquery
 * 
 * pyranja, 2014
 */

//==============================================================>
// NAMESPACE
var asio = (function() {
  var exports = {};

  // ==============================================================>
  // CONSTANTS

  // relative path from site location to asio sql endpoint
  // change this to adapt to deployment location
  /* TODO : do sth clever to guess dynamic catalog endpoint? */
  var ENDPOINT_PATH = "/catalog/public";
  // service suffixes
  var SERVICE_SCHEMA = "/schema";
  var SERVICE_QUERY = "/sql";
  var SERVICE_META = "/meta";

  // ==============================================================>
  // UTILS

  // guess dataset root URL from current location
  // -> strip /explore path from URL
  // -> strip file name and/or trailing slash from URL
  function guessRoot() {
    var base = $(location).attr('href')
      .replace(/\/explore/, '')           // remove explorer page path
      .replace(/([^\/]*).html$/, '')      // remove explorer page name
      .replace(/\/$/, '');                // remove trailing slash
    return base;
  }

  function serviceRoot() {
    return guessRoot() + ENDPOINT_PATH;
  }

  // determine the sql query endpoint of this dataset
  function endpoint() {
    return serviceRoot() + SERVICE_QUERY;
  }
  ;

  // forward a success ajax response to a nodejs style callback
  function forwardTo(callback) {
    return function(result) {
      callback(null, result);
    };
  }
  ;

  // attempt to parse an error response (expected to be json)
  function parseErrorResponse(xhr) {
    var error = JSON.parse(xhr.responseText).error;
    return new Error(xhr.statusText + "\n'" + error.message + "'");
  }<commit_msg>fix error object parsing in asio.js<commit_after>/* 
 * asio - js library
 * 
 * requires jquery
 * 
 * pyranja, 2014
 */

//==============================================================>
// NAMESPACE
var asio = (function() {
  var exports = {};

  // ==============================================================>
  // CONSTANTS

  // relative path from site location to asio sql endpoint
  // change this to adapt to deployment location
  /* TODO : do sth clever to guess dynamic catalog endpoint? */
  var ENDPOINT_PATH = "/catalog/public";
  // service suffixes
  var SERVICE_SCHEMA = "/schema";
  var SERVICE_QUERY = "/sql";
  var SERVICE_META = "/meta";

  // ==============================================================>
  // UTILS

  // guess dataset root URL from current location
  // -> strip /explore path from URL
  // -> strip file name and/or trailing slash from URL
  function guessRoot() {
    var base = $(location).attr('href')
      .replace(/\/explore/, '')           // remove explorer page path
      .replace(/([^\/]*).html$/, '')      // remove explorer page name
      .replace(/\/$/, '');                // remove trailing slash
    return base;
  }

  function serviceRoot() {
    return guessRoot() + ENDPOINT_PATH;
  }

  // determine the sql query endpoint of this dataset
  function endpoint() {
    return serviceRoot() + SERVICE_QUERY;
  }
  ;

  // forward a success ajax response to a nodejs style callback
  function forwardTo(callback) {
    return function(result) {
      callback(null, result);
    };
  }
  ;

  // attempt to parse an error response (expected to be json)
  function parseErrorResponse(xhr) {
    var error = JSON.parse(xhr.responseText);
    return new Error(xhr.statusText + "\n'" + error.message + "'");
  }
{'fraction_non_alphanumeric': 0.2233560090702948, 'fraction_numerical': 0.0022675736961451248, 'mean_word_length': 2.869517543859649, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7474868', 'n_tokens_mistral': 1008, 'n_tokens_neox': 947, 'n_words': 305}