<commit_before>// loadFibers returns a FiberSource array of fibers contained in a JSON file.
function loadFibers( path ) {
  var request = new XMLHttpRequest();
  request.overrideMimeType("text/plain");
  request.open("get", path, false);
  request.send(null);
  // Only geometries are loaded for the moment
  var loaded = JSON.parse(request.response).fiber_geometries;

  // Return will be a FiberSource array for each fiber geometry.
  var fibers = [];
  for (var property in loaded) {
    if (loaded.hasOwnProperty(property)) {
      var fiber = loaded[property.toString()];
      // Control points need to be transleted to array-of-arrays form
      var newcp = [];
      for (var i = 0; i < fiber.control_points.length; i = i + 3) {
        newcp.push([fiber.control_points[i],
                    fiber.control_points[i+1],
                    fiber.control_points[i+2]]);
      }
      fibers.push(new FiberSource(newcp, fiber.tangents, fiber.radius));
    }
  }
  // log an error in case fibers were not found.
  if (fibers.length == 0) console.warn('Any fiber found in file '+path);
  return fibers;
}

// loadRegions returns an IsotropicRegionSource array of regions contained in a JSON file.
function loadRegions( path ) {
  var request = new XMLHttpRequest();
  request.overrideMimeType("text/plain");
  request.open("get", path, false);
  request.send(null);
  // Only geometries are loaded for the moment
  var loaded = JSON.parse(request.response).isotropic_regions;

  // Return will be a FiberSource array for each fiber geometry.
  var regions = [];
  for (var property in loaded) {
    if (loaded.hasOwnProperty(property)) {
      var region = loaded[property.toString()];
      regions.push(new IsotropicRegionSource(region.center, region.radius));
    }
  }
  // log an error in case regions were not found.
  if (regions.length == 0) console.warn('Any region found in file '+path);
  return regions;
}<commit_msg>load.js is now loadPhantom function. Returns phantom object.<commit_after>// loadFibers returns a FiberSource array of fibers contained in a JSON file.
function loadPhantom( path ) {
  var request = new XMLHttpRequest();
  request.overrideMimeType("text/plain");
  request.open("get", path, false);
  request.send(null);

  var phantom = new Phantom();
  var loadedfibers = JSON.parse(request.response).fiber_geometries;
  var loadedregions = JSON.parse(request.response).isotropic_regions;

  // Objects will be added in Phantom
  for (var property in loadedfibers) {
    if (loadedfibers.hasOwnProperty(property)) {
      var fiber = loadedfibers[property.toString()];
      // Control points need to be transleted to array-of-arrays form
      var newcp = [];
      for (var i = 0; i < fiber.control_points.length; i = i + 3) {
        newcp.push([fiber.control_points[i],
                    fiber.control_points[i+1],
                    fiber.control_points[i+2]]);
      }
      phantom.AddFiber(new FiberSource(newcp, fiber.tangents, fiber.radius));
    }
  }
  for (var property in loadedregions) {
    if (loadedregions.hasOwnProperty(property)) {
      var region = loadedregions[property.toString()];
      phantom.AddIsotropicRegion(new IsotropicRegionSource(region.center, region.radius));
    }
  }

  // log an error in case fibers or regions were not found.
  if (phantom.isotropicregions.length == 0) console.warn('Any region found in file '+path);
  if (phantom.fibers.length == 0) console.warn('Any fiber found in file '+path);
  return phantom;
}
{'fraction_non_alphanumeric': 0.11450599657338664, 'fraction_numerical': 0.0034266133637921186, 'mean_word_length': 3.3569651741293534, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6299800', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1016, 'n_words': 312}