<commit_before>! function (definition) {
  if (typeof window != "undefined") window.inquiry = definition();
  else if (typeof define == "function") define(definition);
  else module.exports = definition();
} (function () {
  function parse (rest, fixup, nesting, stop) {
    var expression = [], slash = '/', args, struct, source, i, $, mod;
    rest = rest.trim()
    while (rest && rest[0] != stop) {
      if (rest[0] != '/') {
        if (/^[>![{]/.test(rest[0])) {
          rest = '/.' + rest;
        } else {
          rest = slash + rest;
        }
      }
      // todo: can you fold this into the regex somehow?
      var descend = false
      if (rest[1] == '/') {
        descend = true
        rest = rest.substring(1)
      }
      slash = '';
      $ = /^\/((?:!(?![[{])|[^>![{/`"\]]|"(?:[^\\"]|\\.)*")*)(([>!]?)([[{]))?(.*)/.exec(rest);
      console.log($)
      if (!$) throw new Error("bad pattern");
      //struct = [ /^['"]/.test($[1].trim()) ? $[1].trim().replace(/^(['"])(.*)\1$/g, "$2").replace(/\\(.)/g, "$1") : decodeURIComponent($[1].trim()) ]
      struct = [ /^"/.exec($[1].trim()) ? JSON.parse($[1].trim()) : decodeURIComponent($[1].trim()) ]
      rest = $[5];
      // Check for have a predicate or a sub-expression.
      switch ($[4]) {
      // We want to consume the contents of the curly braces that define a
      // predicate to construct a function body.
      case "{":
        // Depth is the number of curly braces we've encountered. We match curly
        // braces until it is time to pop.
        // **TODO**: Test against regular expressions. We are going to have to
        // document the one valid regular expression that we know of that we
        // cannot match: `/[/]/`.
        mod = $[3]
        if (mod == '>') {
            $[3] = ''
        }
        source = $[3] + '(';
        $ = /^(((?:[^'"}]*|'(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*")*)})/.exec(rest);
        if (!$) throw new Error("bad pattern");
        source += $[2];
        rest = rest.substring($[1].length);
        args = ['_'];
        for (i = 0; i < nesting; i++) {
          args.push(Array(i + 2).join('$'), Array(i + 2).join('$') + 'i');
        }
        args.push.apply(args, fixup)
        $ = 0; // evil reuse of `$` to count airty. for the bytes, always for the bytes
        source.replace(/\$(\d+)/g, function (_, number) { $ = Math.max($, +number) });
        for (i = 0; i < $; i++) {
          args.push('$' + (i + 1));
        }
        args.push('return ' +  source + ')');
        if (mod == '>') {
            struct.push((function (predicate) {
              return function (candidate, vargs) {
                var result = predicate.apply(this, [ candidate._, candidate.o, candidate.i ].concat(vargs))
                if (result === (void(0))) {
                    return []
                }
                if (!Array.isArray(result)) {
                    result = [ result ]
                }
                return result.map(function (result, index) {
                    return { _: candidate._, o: result, i: index }
                })
              }
            })(Function.apply(Function, args)));
        } else {
            struct.push((function (predicate) {
              return function (candidate, vargs) {
                return predicate.apply(this, [ candidate._, candidate.o, candidate.i ].concat(vargs))
                     ? [ candidate ] : []
              }
            })(Function.apply(Function, args)));
        }
        break;
      // We want to consume the contents of brackets as a sub-expression, so we
      // call ourselves recursively.
      case "[":
        struct.push((function (negate, subquery) {
          return function (candidate, args) {
            var length = subquery.call(this, candidate, [ candidate.o, candidate.i ].concat(args)).length;
            return (negate ? ! length : length) ? [ candidate ] : [];
          }
        })($[3] == '!', ($ = parse(rest, fixup, nesting + 1, "]"))[0]));
        rest = $[1].slice(1);
        break;
      default:
        struct.push(null);
      }
      struct.push(descend);
      expression.push(struct);
      rest = rest.trim()
    }
    return [ function (candidate, vargs) {
      var candidates = [], stack = [ candidate ],
          star,  i, j, path, object, _;
      // todo: we might be able to get: div/p/3 (third paragraph)
      // todo: we might be able to get: .{ $.tag == 'div' }/.{ $.tag == 'p' }/3 (third paragraph)
      // todo: appears as though .o is just .p[0] so why both?
      // todo: _ appears to track the path, appears in correct for arrays, and
      // appears unused, not returned to the user.
      for (i = 0; i < expression.length; i++) {
        while (stack.length) {
          candidate = stack.shift(), object = candidate.o, path = candidate.p, _ = candidate._;
          console.log(expression[i])
          if (expression[i][2] && !Array.isArray(object)) {
            console.log('here')
            for (var key in object) {
                console.log(object, key)
              stack.unshift({ o: object[key], _: [ key ].concat(_), p: [ object[key] ].concat(path) });
            }
          }
          if (object[expression[i][0]] !== (void(0))) {
            candidates.push({ o: object[expression[i][0]], _: [ expression[i][0] ].concat(_), p: [ object ].concat(path) });
          } else if (expression[i][0] == '.') {
            candidates.push(candidate);
          } else if (expression[i][0] == '..') {
            path = path.slice();<commit_msg>Remove debugging statements.<commit_after>! function (definition) {
  if (typeof window != "undefined") window.inquiry = definition();
  else if (typeof define == "function") define(definition);
  else module.exports = definition();
} (function () {
  function parse (rest, fixup, nesting, stop) {
    var expression = [], slash = '/', args, struct, source, i, $, mod;
    rest = rest.trim()
    while (rest && rest[0] != stop) {
      if (rest[0] != '/') {
        if (/^[>![{]/.test(rest[0])) {
          rest = '/.' + rest;
        } else {
          rest = slash + rest;
        }
      }
      // todo: can you fold this into the regex somehow?
      var descend = false
      if (rest[1] == '/') {
        descend = true
        rest = rest.substring(1)
      }
      slash = '';
      $ = /^\/((?:!(?![[{])|[^>![{/`"\]]|"(?:[^\\"]|\\.)*")*)(([>!]?)([[{]))?(.*)/.exec(rest);
      if (!$) throw new Error("bad pattern");
      //struct = [ /^['"]/.test($[1].trim()) ? $[1].trim().replace(/^(['"])(.*)\1$/g, "$2").replace(/\\(.)/g, "$1") : decodeURIComponent($[1].trim()) ]
      struct = [ /^"/.exec($[1].trim()) ? JSON.parse($[1].trim()) : decodeURIComponent($[1].trim()) ]
      rest = $[5];
      // Check for have a predicate or a sub-expression.
      switch ($[4]) {
      // We want to consume the contents of the curly braces that define a
      // predicate to construct a function body.
      case "{":
        // Depth is the number of curly braces we've encountered. We match curly
        // braces until it is time to pop.
        // **TODO**: Test against regular expressions. We are going to have to
        // document the one valid regular expression that we know of that we
        // cannot match: `/[/]/`.
        mod = $[3]
        if (mod == '>') {
            $[3] = ''
        }
        source = $[3] + '(';
        $ = /^(((?:[^'"}]*|'(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*")*)})/.exec(rest);
        if (!$) throw new Error("bad pattern");
        source += $[2];
        rest = rest.substring($[1].length);
        args = ['_'];
        for (i = 0; i < nesting; i++) {
          args.push(Array(i + 2).join('$'), Array(i + 2).join('$') + 'i');
        }
        args.push.apply(args, fixup)
        $ = 0; // evil reuse of `$` to count airty. for the bytes, always for the bytes
        source.replace(/\$(\d+)/g, function (_, number) { $ = Math.max($, +number) });
        for (i = 0; i < $; i++) {
          args.push('$' + (i + 1));
        }
        args.push('return ' +  source + ')');
        if (mod == '>') {
            struct.push((function (predicate) {
              return function (candidate, vargs) {
                var result = predicate.apply(this, [ candidate._, candidate.o, candidate.i ].concat(vargs))
                if (result === (void(0))) {
                    return []
                }
                if (!Array.isArray(result)) {
                    result = [ result ]
                }
                return result.map(function (result, index) {
                    return { _: candidate._, o: result, i: index }
                })
              }
            })(Function.apply(Function, args)));
        } else {
            struct.push((function (predicate) {
              return function (candidate, vargs) {
                return predicate.apply(this, [ candidate._, candidate.o, candidate.i ].concat(vargs))
                     ? [ candidate ] : []
              }
            })(Function.apply(Function, args)));
        }
        break;
      // We want to consume the contents of brackets as a sub-expression, so we
      // call ourselves recursively.
      case "[":
        struct.push((function (negate, subquery) {
          return function (candidate, args) {
            var length = subquery.call(this, candidate, [ candidate.o, candidate.i ].concat(args)).length;
            return (negate ? ! length : length) ? [ candidate ] : [];
          }
        })($[3] == '!', ($ = parse(rest, fixup, nesting + 1, "]"))[0]));
        rest = $[1].slice(1);
        break;
      default:
        struct.push(null);
      }
      struct.push(descend);
      expression.push(struct);
      rest = rest.trim()
    }
    return [ function (candidate, vargs) {
      var candidates = [], stack = [ candidate ],
          star,  i, j, path, object, _;
      // todo: we might be able to get: div/p/3 (third paragraph)
      // todo: we might be able to get: .{ $.tag == 'div' }/.{ $.tag == 'p' }/3 (third paragraph)
      // todo: appears as though .o is just .p[0] so why both?
      // todo: _ appears to track the path, appears in correct for arrays, and
      // appears unused, not returned to the user.
      for (i = 0; i < expression.length; i++) {
        while (stack.length) {
          candidate = stack.shift(), object = candidate.o, path = candidate.p, _ = candidate._;
          if (expression[i][2] && !Array.isArray(object)) {
            for (var key in object) {
              stack.unshift({ o: object[key], _: [ key ].concat(_), p: [ object[key] ].concat(path) });
            }
          }
          if (object[expression[i][0]] !== (void(0))) {
            candidates.push({ o: object[expression[i][0]], _: [ expression[i][0] ].concat(_), p: [ object ].concat(path) });
          } else if (expression[i][0] == '.') {
            candidates.push(candidate);
          } else if (expression[i][0] == '..') {
            path = path.slice();
{'fraction_non_alphanumeric': 0.19790528233151183, 'fraction_numerical': 0.008014571948998178, 'mean_word_length': 1.8265122265122264, 'pattern_counts': {'":': 4, '<': 9, '<?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': '3977469', 'n_tokens_mistral': 3388, 'n_tokens_neox': 3319, 'n_words': 890}