<commit_before>function filterblocks(a) {
  // Show 'say' block only on browsers that support speech synthesis.
  if (!window.SpeechSynthesisUtterance || !window.speechSynthesis) {
    a = a.filter(function(b) { return !/^@?say\b/.test(b.block); });
  }
  return a.map(function(e) {
    if (!e.id) {
      e.id = e.block.replace(/\W..*$/, '');
    }
    return e;
  });
}

// Recursive copy of a plain javascript object, while mapping
// specified fields.
function fieldmap(obj, map) {
  if (!obj || 'object' != typeof obj) {
    return obj;
  }
  var result;
  if (obj instanceof Array) {
    result = [];
    for (var j = 0; j < obj.length; ++j) {
      result.push(fieldmap(obj[j], map));
    }
  } else {
    result = {};
    for (var k in obj) if (obj.hasOwnProperty(k)) {
      if (map.hasOwnProperty(k)) {
        result[k] = map[k](obj[k]);
      } else {
        result[k] = fieldmap(obj[k], map);
      }
    }
  }
  return result;
}

function expand(palette, thisname) {
  var replacement = !thisname ? '' : (thisname + '.');
  function replacer(s) {
    if (!s) return s;
    return s.replace(/@/, replacement);
  }
  return fieldmap(palette, {
    block: replacer,
    expansion: replacer
  });
}

var distances = ['25', '50', '100', '200'],
    sdistances = ['100', '50', '-50', '-100'],
    angles = ['30', '45', '60', '90', '135', '144'],
    sangles = ['0', '90', '180', '270'],
    sizes = ['10', '25', '50', '100'],
    scales = ['0.5', '2.0', '3.0'],
    colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'black'];

module.exports = {

  expand: expand,

  // The following palette description
  // is copied from compiled CoffeeScript.
  COFFEESCRIPT_PALETTE: [
    {
      name: 'Move',
      color: 'lightblue',
      blocks: filterblocks([
        {
          block: '@fd 100',
          title: 'Move forward'
        }, {
          block: '@rt 90',
          title: 'Turn right'
        }, {
          block: '@lt 90',
          title: 'Turn left'
        }, {
          block: '@bk 100',
          title: 'Move backward'
        }, {
          block: '@rt 180, 100',
          title: 'Make a wide right arc'
        }, {
          block: '@lt 180, 100',
          title: 'Make a wide left arc'
        }, {
          block: '@speed 10',
          title: 'Set the speed of the turtle'
        }, {
          block: '@speed Infinity',
          title: 'Use infinite speed'
        }, {
          block: '@home()',
          title: 'Jump to the origin, turned up'
        }, {
          block: '@turnto 270',
          title: 'Turn to an absolute direction'
        }, {
          block: '@turnto lastclick',
          title: 'Turn toward a located object'
        }, {
          block: '@moveto 100, 50',
          title: 'Move to coordinates'
        }, {
          block: '@movexy 30, 20',
          title: 'Move by changing x and y'
        }, {
          block: '@jumpto 100, 50',
          title: 'Jump to coordinates without drawing'
        }, {
          block: '@jumpxy 30, 20',
          title: 'Jump changing x and y without drawing'
        }
      ])
    }, {
      name: 'Control',
      color: 'orange',
      blocks: filterblocks([
        {
          block: 'for [1..3]\n  ``',
          title: 'Do something multiple times'
        }, {
          block: 'for i in [0...3]\n  ``',
          title: '  Repeat soemething with a loop variable'
        }, {
          block: 'if `` is ``\n  ``',
          title: 'Do something only if a condition is true'
        }, {
          block: 'if `` is ``\n  ``\nelse\n  ``',
          title:
              'Do something if a condition is true, otherwise something else',
          id: 'ifelse'
        }, {
          block: "forever 1, ->\n  ``",
          title: 'Repeat something forever at qually-spaced times'
        }, {
          block: "button \'Click\', ->\n  ``",
          title: 'Make a button and do something when clicked'
        }, {
          block: "keydown \'X\', ->\n  ``",
          title: 'Do something when a keyboard key is pressed'<commit_msg>Add while to the palette.<commit_after>function filterblocks(a) {
  // Show 'say' block only on browsers that support speech synthesis.
  if (!window.SpeechSynthesisUtterance || !window.speechSynthesis) {
    a = a.filter(function(b) { return !/^@?say\b/.test(b.block); });
  }
  return a.map(function(e) {
    if (!e.id) {
      e.id = e.block.replace(/\W..*$/, '');
    }
    return e;
  });
}

// Recursive copy of a plain javascript object, while mapping
// specified fields.
function fieldmap(obj, map) {
  if (!obj || 'object' != typeof obj) {
    return obj;
  }
  var result;
  if (obj instanceof Array) {
    result = [];
    for (var j = 0; j < obj.length; ++j) {
      result.push(fieldmap(obj[j], map));
    }
  } else {
    result = {};
    for (var k in obj) if (obj.hasOwnProperty(k)) {
      if (map.hasOwnProperty(k)) {
        result[k] = map[k](obj[k]);
      } else {
        result[k] = fieldmap(obj[k], map);
      }
    }
  }
  return result;
}

function expand(palette, thisname) {
  var replacement = !thisname ? '' : (thisname + '.');
  function replacer(s) {
    if (!s) return s;
    return s.replace(/@/, replacement);
  }
  return fieldmap(palette, {
    block: replacer,
    expansion: replacer
  });
}

var distances = ['25', '50', '100', '200'],
    sdistances = ['100', '50', '-50', '-100'],
    angles = ['30', '45', '60', '90', '135', '144'],
    sangles = ['0', '90', '180', '270'],
    sizes = ['10', '25', '50', '100'],
    scales = ['0.5', '2.0', '3.0'],
    colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'black'];

module.exports = {

  expand: expand,

  // The following palette description
  // is copied from compiled CoffeeScript.
  COFFEESCRIPT_PALETTE: [
    {
      name: 'Move',
      color: 'lightblue',
      blocks: filterblocks([
        {
          block: '@fd 100',
          title: 'Move forward'
        }, {
          block: '@rt 90',
          title: 'Turn right'
        }, {
          block: '@lt 90',
          title: 'Turn left'
        }, {
          block: '@bk 100',
          title: 'Move backward'
        }, {
          block: '@rt 180, 100',
          title: 'Make a wide right arc'
        }, {
          block: '@lt 180, 100',
          title: 'Make a wide left arc'
        }, {
          block: '@speed 10',
          title: 'Set the speed of the turtle'
        }, {
          block: '@speed Infinity',
          title: 'Use infinite speed'
        }, {
          block: '@home()',
          title: 'Jump to the origin, turned up'
        }, {
          block: '@turnto 270',
          title: 'Turn to an absolute direction'
        }, {
          block: '@turnto lastclick',
          title: 'Turn toward a located object'
        }, {
          block: '@moveto 100, 50',
          title: 'Move to coordinates'
        }, {
          block: '@movexy 30, 20',
          title: 'Move by changing x and y'
        }, {
          block: '@jumpto 100, 50',
          title: 'Jump to coordinates without drawing'
        }, {
          block: '@jumpxy 30, 20',
          title: 'Jump changing x and y without drawing'
        }
      ])
    }, {
      name: 'Control',
      color: 'orange',
      blocks: filterblocks([
        {
          block: 'for [1..3]\n  ``',
          title: 'Do something multiple times'
        }, {
          block: 'while ``\n  ``',
          title: '  Repeat while a condition is true'
        }, {
          block: 'if `` is ``\n  ``',
          title: 'Do something only if a condition is true'
        }, {
          block: 'if `` is ``\n  ``\nelse\n  ``',
          title:
              'Do something if a condition is true, otherwise something else',
          id: 'ifelse'
        }, {
          block: "forever 1, ->\n  ``",
          title: 'Repeat something forever at qually-spaced times'
        }, {
          block: "button \'Click\', ->\n  ``",
          title: 'Make a button and do something when clicked'
        }, {
          block: "keydown \'X\', ->\n  ``",
          title: 'Do something when a keyboard key is pressed'
{'fraction_non_alphanumeric': 0.16765140324963074, 'fraction_numerical': 0.026587887740029542, 'mean_word_length': 1.7777777777777777, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5734085', 'n_tokens_mistral': 2757, 'n_tokens_neox': 2561, 'n_words': 775}