<commit_before>'use strict';

var path = require('path');
var fileRe = require('filename-regex');
var win32 = process.platform === 'win32';
var win;

var utils = module.exports;

function makeGlobstar(a, b) {
  if (a === '.' || a === '/') {
    a = '';
  }
  if (a.indexOf('/') === -1) {
    return b;
  }
  if (a.slice(-1) === '/') {
    a = a.slice(a.length - 1);
  }
  if (b.charAt(0) === '/') {
    b = b.slice(1);
  }
  return a + '/' + b;
}

utils.filename = function filename(fp) {
  var seg = fp.match(fileRe());
  return seg && seg[0];
};

utils.isPath = function isPath(pattern) {
  return function (fp) {
    return fp === pattern;
  }
};

utils.hasPath = function hasPath(pattern, opts) {
  return function (fp) {
    return fp.indexOf(pattern) !== -1;
  }
};

utils.matchPath = function matchPath(pattern, opts) {
  var fn = (opts && opts.contains)
    ? utils.hasPath(pattern)
    : utils.isPath(pattern);
  return fn;
};

utils.hasFilename = function hasFilename(re, opts) {
  return function (fp) {
    var name = utils.filename(fp);
    return name && re.test(name);
  }
};

/**
 * Coerce `val` to an array
 *
 * @param  {*} val
 * @return {Array}
 */

utils.arrayify = function arrayify(val) {
  return !Array.isArray(val)
    ? [val]
    : val;
};

/**
 * Convert a file path to a unix path.
 */

utils.unixify = function unixify(fp, opts) {
  if (opts && opts.unixify === true) {
    win = true;
  } else if (opts && opts.cache && typeof win === 'undefined') {
    win = win32 || path.sep === '\\';
  }
  if (win) {
    return fp.replace(/[\\\/]+/g, '/');
  }
  return fp;
};

/**
 * Escape/unescape utils
 */

utils.escapePath = function escapePath(fp) {
  return fp.replace(/[\\.]/g, '\\$&');
};

utils.unescapeGlob = function unescapeGlob(fp) {
  return fp.replace(/[\\"']/g, '');
};

utils.escapeRe = function escapeRe(str) {
  return str.replace(/[\]-[\\$*+?.#^\s{}(|)]/g, '\\$&');
};
<commit_msg>clean up utils<commit_after>'use strict';

var path = require('path');
var fileRe = require('filename-regex');
var win32 = process.platform === 'win32';
var win;

var utils = module.exports;

utils.filename = function filename(fp) {
  var seg = fp.match(fileRe());
  return seg && seg[0];
};

utils.isPath = function isPath(pattern) {
  return function (fp) {
    return fp === pattern;
  }
};

utils.hasPath = function hasPath(pattern, opts) {
  return function (fp) {
    return fp.indexOf(pattern) !== -1;
  }
};

utils.matchPath = function matchPath(pattern, opts) {
  var fn = (opts && opts.contains)
    ? utils.hasPath(pattern)
    : utils.isPath(pattern);
  return fn;
};

utils.hasFilename = function hasFilename(re, opts) {
  return function (fp) {
    var name = utils.filename(fp);
    return name && re.test(name);
  }
};

/**
 * Coerce `val` to an array
 *
 * @param  {*} val
 * @return {Array}
 */

utils.arrayify = function arrayify(val) {
  return !Array.isArray(val)
    ? [val]
    : val;
};

/**
 * Convert a file path to a unix path.
 */

utils.unixify = function unixify(fp, opts) {
  if (opts && opts.unixify === true) {
    win = true;
  } else if (opts && opts.cache && typeof win === 'undefined') {
    win = win32 || path.sep === '\\';
  }
  if (win) {
    return fp.replace(/[\\\/]+/g, '/');
  }
  return fp;
};

/**
 * Escape/unescape utils
 */

utils.escapePath = function escapePath(fp) {
  return fp.replace(/[\\.]/g, '\\$&');
};

utils.unescapeGlob = function unescapeGlob(fp) {
  return fp.replace(/[\\"']/g, '');
};

utils.escapeRe = function escapeRe(str) {
  return str.replace(/[\]-[\\$*+?.#^\s{}(|)]/g, '\\$&');
};

{'fraction_non_alphanumeric': 0.21224832214765102, 'fraction_numerical': 0.00587248322147651, 'mean_word_length': 2.9612403100775193, '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': '1717898', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1341, 'n_words': 300}