<commit_before>
var fs = require('fs');
var path = require('path');
var walk = require('fs-walk');
var crypto = require('crypto');

var dupMods = {};
var imageExtname = /jpg|gif|png|tif$/i;
var logFile = __dirname + './../results.txt';
var records = {};
var dupCount = 0;

module.exports = dupMods;

dupMods.prepare = function (fn) {
  console.log('');
  records = {}; // Clear the cached records from previous scans
  dupCount = 0; // Reset the dup count from previous scans
  var now = new Date().toString();
  fs.writeFile(logFile, now + '\r\n\r\n', function (err) {
    if (err) {
      return fn(err);
    }
    fn(null);
  });
};

dupMods.getImages = function (dir, fn) {
  var files = [];
  console.log('fetching images from all directories in ' + dir);
  walk.walkSync(dir, function (basedir, filename) {
    files.push(path.join(basedir, filename));
  });
  fn(null, files.filter(dupMods.isImage));
};

<commit_msg>[update] utils.js (adds more descriptive text content for results.txt)<commit_after>
var fs = require('fs');
var path = require('path');
var walk = require('fs-walk');
var crypto = require('crypto');

var dupMods = {};
var imageExtname = /jpg|gif|png|tif$/i;
var logFile = __dirname + './../results.txt';
var records = {};
var dupCount = 0;

module.exports = dupMods;

dupMods.prepare = function (fn) {
  console.log('');
  records = {}; // Clear the cached records from previous scans
  dupCount = 0; // Reset the dup count from previous scans
  var now = new Date().toString();
  fs.writeFile(logFile, 'Scan complete: ' + now + '\r\n\r\n', function (err) {
    if (err) {
      return fn(err);
    }
    fn(null);
  });
};

dupMods.getImages = function (dir, fn) {
  var files = [];
  console.log('fetching images from all directories in ' + dir);
  walk.walkSync(dir, function (basedir, filename) {
    files.push(path.join(basedir, filename));
  });
  fn(null, files.filter(dupMods.isImage));
};


{'fraction_non_alphanumeric': 0.1735064935064935, 'fraction_numerical': 0.002077922077922078, 'mean_word_length': 3.6634382566585955, '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': '5342136', 'n_tokens_mistral': 660, 'n_tokens_neox': 641, 'n_words': 180}