<commit_before>var frontMatter = require('front-matter');
var cat = require('shelljs').cat;
var path = require('path');

module.exports = function(file, rootDir) {
  var contents = cat(file);
  var fm;

  // in some cases (hexo), the front matter doesn't have the leading `---`
  // but it is valid yaml and always starts with 'title'
  if (contents.slice(0, 5) === 'title') {
    contents = '---\n' + contents;
  }

  fm = frontMatter(contents);
  fm.path = file.replace(rootDir, '.');
  fm.fileName = fm.path.slice(fm.path.lastIndexOf(path.sep), fm.path.lastIndexOf('.'));

  return fm;
};
<commit_msg>fixed wrong slice<commit_after>var frontMatter = require('front-matter');
var cat = require('shelljs').cat;
var path = require('path');

module.exports = function(file, rootDir) {
  var contents = cat(file);
  var fm;

  // in some cases (hexo), the front matter doesn't have the leading `---`
  // but it is valid yaml and always starts with 'title'
  if (contents.slice(0, 5) === 'title') {
    contents = '---\n' + contents;
  }

  fm = frontMatter(contents);
  fm.path = file.replace(rootDir, '.');
  fm.fileName = fm.path.slice(fm.path.lastIndexOf(path.sep) + 1, fm.path.lastIndexOf('.'));

  return fm;
};

{'fraction_non_alphanumeric': 0.17845394736842105, 'fraction_numerical': 0.004111842105263158, 'mean_word_length': 3.6628352490421454, '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': '795057', 'n_tokens_mistral': 437, 'n_tokens_neox': 411, 'n_words': 111}