<commit_before>// Contains helper functions related to the filesystem.

const fs = require('fs');
const path = require('path');

function isDirectory(filePath) {
  return fs.statSync(filePath).isDirectory();
}

function getFileContents(filePath) {
  return fs.readFileSync(filePath, {
    // UTF-8 encoding so that we get a string instead of bytes.
    encoding: 'utf-8'
  });
}

// Splits the filename into named parts.
//
// We don't have access to the Roblox Studio Properties panel, so we have to add
// on ClassName identifiers to the filenames.
//
// Our files will typically look like 'Filename.class.lua', where 'class' can be
// 'module', 'local' or 'script'. These are used as ClassName identifiers so
// that we can later turn them into Roblox's supported ClassNames.
//
// Example:
//
//  splitBasename('Helpers.module.lua')
//  { name: 'Helpers', classIdentifier: 'module', ext: '.lua' }
function splitBasename(filePath) {
  const parsed = path.parse(filePath);
  const parts = parsed.name.split('.');

  return {
    name: parts[0],
    classIdentifier: parts[1],
    ext: parsed.ext
  };
}

module.exports = {
  isDirectory,
  getFileContents,
  splitBasename
};
<commit_msg>Export file helper functions directly<commit_after>// Contains helper functions related to the filesystem.

const fs = require('fs');
const path = require('path');

exports.isDirectory = function(filePath) {
  return fs.statSync(filePath).isDirectory();
}

exports.getFileContents = function(filePath) {
  return fs.readFileSync(filePath, {
    // UTF-8 encoding so that we get a string instead of bytes.
    encoding: 'utf-8'
  });
}

// Splits the filename into named parts.
//
// We don't have access to the Roblox Studio Properties panel, so we have to add
// on ClassName identifiers to the filenames.
//
// Our files will typically look like 'Filename.class.lua', where 'class' can be
// 'module', 'local' or 'script'. These are used as ClassName identifiers so
// that we can later turn them into Roblox's supported ClassNames.
//
// Example:
//
//  splitBasename('Helpers.module.lua')
//  { name: 'Helpers', classIdentifier: 'module', ext: '.lua' }
exports.splitBasename = function(filePath) {
  const parsed = path.parse(filePath);
  const parts = parsed.name.split('.');

  return {
    name: parts[0],
    classIdentifier: parts[1],
    ext: parsed.ext
  };
}

{'fraction_non_alphanumeric': 0.13002964845404488, 'fraction_numerical': 0.0033883947479881405, 'mean_word_length': 3.6865079365079363, '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': '5244219', 'n_tokens_mistral': 719, 'n_tokens_neox': 708, 'n_words': 242}