<commit_before>var _ = fis.util;

exports.name = 'inspect [media name]';
exports.desc = 'inspect the result of fis.match ';
exports.options = {
  '-h, --help': 'print this help message',
  '--files'   : 'specify files to be inspected.'
};

exports.run = function(argv, cli) {
  if (argv.h || argv.help) {
    return cli.help(exports.name, exports.options);
  }

  // 如果指定了 media 值
  if (argv._[1]) {
    process.env.NODE_ENV = argv._[1];
  }

  var specified = argv.files;
  var pattern = fis.media().get('project.files');

  if (specified && typeof specified === 'string' && specified !== '::package') {
    pattern = specified.split(/\s*,\s*/);
  }

  var files = fis.project.getSourceByPatterns(pattern);
  var stream = process.stdout;
  var matches = fis.media().getSortedMatches();

  function inspect(value) {
    if (Array.isArray(value)) {
      return '[' + value.map(function(value, _index) {
        if (value && value.__plugin) {
          return ('[plugin `' + value.__plugin + '`]').cyan;
        } else if (fis.util.is(value, 'Function')) {
          return funcToString(value, _index);
        }
        return value;
      }).join(', ') + ']';
    } else if (value && value.__plugin) {
      return ('[plugin `' + funcToString(value.__plugin) + '`]').cyan;
    } else if (fis.util.is(value, 'Function')) {
      return funcToString(value);
    }

    return value;
  }
  function funcToString(fn, _index) {
    if (!fis.util.is(fn, 'Function')) {
      return fn;
    }
    var match = fn.toString().match(/^function\s*(\w+)?\s*\(([, \w]*)\)/);
    if (match) {
      return 'function'+ RegExp.$1 +' (' + RegExp.$2 + ') { ... }'
    }
    return fn;
  }

  function output(entry, data) {
    var str = '\n ~ '.bold.yellow;
    var flag = false;

    str += entry + '\n';

    Object.keys(data).forEach(function(key) {
      if (/^__(.*)Index$/.test(key) && RegExp.$1.substr(-1) !== 'F') {
        var propKey = RegExp.$1;
        flag = true;
        str += ' -- ' + propKey + ' ' + inspect(data[propKey]) + ' `' + (matches[data[key]].raw + '').blue + '`   (' + data[key] + 'th)\n';
      }
    });

    if (!flag) {
      str += ' -- empty';
    }
    console.log(str);
  }

  Object.keys(files).forEach(function(subpath) {
    var file = files[subpath];<commit_msg>加个空格，美化格式<commit_after>var _ = fis.util;

exports.name = 'inspect [media name]';
exports.desc = 'inspect the result of fis.match ';
exports.options = {
  '-h, --help': 'print this help message',
  '--files'   : 'specify files to be inspected.'
};

exports.run = function(argv, cli) {
  if (argv.h || argv.help) {
    return cli.help(exports.name, exports.options);
  }

  // 如果指定了 media 值
  if (argv._[1]) {
    process.env.NODE_ENV = argv._[1];
  }

  var specified = argv.files;
  var pattern = fis.media().get('project.files');

  if (specified && typeof specified === 'string' && specified !== '::package') {
    pattern = specified.split(/\s*,\s*/);
  }

  var files = fis.project.getSourceByPatterns(pattern);
  var stream = process.stdout;
  var matches = fis.media().getSortedMatches();

  function inspect(value) {
    if (Array.isArray(value)) {
      return '[' + value.map(function(value, _index) {
        if (value && value.__plugin) {
          return ('[plugin `' + value.__plugin + '`]').cyan;
        } else if (fis.util.is(value, 'Function')) {
          return funcToString(value, _index);
        }
        return value;
      }).join(', ') + ']';
    } else if (value && value.__plugin) {
      return ('[plugin `' + funcToString(value.__plugin) + '`]').cyan;
    } else if (fis.util.is(value, 'Function')) {
      return funcToString(value);
    }

    return value;
  }
  function funcToString(fn, _index) {
    if (!fis.util.is(fn, 'Function')) {
      return fn;
    }
    var match = fn.toString().match(/^function\s*(\w+)?\s*\(([, \w]*)\)/);
    if (match) {
      return 'function '+ RegExp.$1 +' (' + RegExp.$2 + ') { ... }'
    }
    return fn;
  }

  function output(entry, data) {
    var str = '\n ~ '.bold.yellow;
    var flag = false;

    str += entry + '\n';

    Object.keys(data).forEach(function(key) {
      if (/^__(.*)Index$/.test(key) && RegExp.$1.substr(-1) !== 'F') {
        var propKey = RegExp.$1;
        flag = true;
        str += ' -- ' + propKey + ' ' + inspect(data[propKey]) + ' `' + (matches[data[key]].raw + '').blue + '`   (' + data[key] + 'th)\n';
      }
    });

    if (!flag) {
      str += ' -- empty';
    }
    console.log(str);
  }

  Object.keys(files).forEach(function(subpath) {
    var file = files[subpath];
{'fraction_non_alphanumeric': 0.20525739320920044, 'fraction_numerical': 0.0030668127053669223, 'mean_word_length': 2.5231481481481484, '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': '1125613', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1591, 'n_words': 327}