<commit_before>var Slm = require('./slm');

function Brackets() {
  this.blockRe = /^(case|default)\b/;
  this.wrapCondRe = /^(for|switch|catch|while|if|else\s+if)\s+(?!\()((\S|\s\S)*)\s*$/
  this.callbackRe = /(function\s*\([^\)]*\)\s*)[^\{]/;
}

var BracketsProto = Brackets.prototype = new Slm;

BracketsProto.on_slm_control = function(exps) {
  var code = exps[2], content = exps[3], m;

  if (m = this.wrapCondRe.exec(code)) {
    code = code.replace(m[2], '(' + m[2] + ')');
  }

  if (!this.blockRe.test(code) && !this.isEmptyExp(content)) {
    code += '{';
    content.push(['code', '}']);
  }
  return ['slm', 'control', code, this.compile(content)]
}

BracketsProto.on_slm_output = function(exps) {
  var code = exps[3], content = exps[4];
  if (!this.blockRe.test(code) && !this.isEmptyExp(content)) {
    var m;
    if (m = this.callbackRe.exec(code)) {
      var index = m.index + m[1].length;
      var codePre = code.slice(0, index);
      var codePost = code.slice(index);
      code = codePre + '{';
      content.push(['code', '}' + codePost])
    } else {
      code += '{';
      content.push(['code', '}']);
    }
  }
  return ['slm', 'output', exps[2], code, this.compile(content)];
}

module.exports = Brackets;
<commit_msg>Code cleanup<commit_after>var Slm = require('./slm');

function Brackets() {
  this.blockRe = /^(case|default)\b/;
  this.wrapCondRe = /^(for|switch|catch|while|if|else\s+if)\s+(?!\()((\S|\s\S)*)\s*$/
  this.callbackRe = /(function\s*\([^\)]*\)\s*)[^\{]/;
}

var BracketsProto = Brackets.prototype = new Slm;

BracketsProto.on_slm_control = function(exps) {
  var code = exps[2], content = exps[3], m;

  if (m = this.wrapCondRe.exec(code)) {
    code = code.replace(m[2], '(' + m[2] + ')');
  }

  if (!this.blockRe.test(code) && !this.isEmptyExp(content)) {
    code += '{';
    content.push(['code', '}']);
  }
  return ['slm', 'control', code, this.compile(content)]
}

BracketsProto.on_slm_output = function(exps) {
  var code = exps[3], content = exps[4], postCode = '}', m;
  if (!this.blockRe.test(code) && !this.isEmptyExp(content)) {
    if (m = this.callbackRe.exec(code)) {
      var index = m.index + m[1].length;
      postCode += code.slice(index);
      code = code.slice(0, index);
    }
    code += '{';
    content.push(['code', postCode]);
  }
  return ['slm', 'output', exps[2], code, this.compile(content)];
}

module.exports = Brackets;

{'fraction_non_alphanumeric': 0.23380398671096345, 'fraction_numerical': 0.007475083056478406, 'mean_word_length': 3.4860335195530725, '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': '3590061', 'n_tokens_mistral': 951, 'n_tokens_neox': 925, 'n_words': 157}