<commit_before>var fs = require('fs');
var path = require('path');
var indent = require('../lib/indent.js/indent.min.js');

/**
 * Generates a complete sync function from the specified document definitions file.
 *
 * @param {string} docDefinitionsFile The path to the document definitions file
 *
 * @returns The full contents of the sync function generated from the specified document definitions file
 */
exports.load = function(docDefinitionsFile) {
  var syncFuncTemplateDir = path.dirname(module.filename);

  function readSyncFunctionFragment(fullMatch, fragmentFilename) {
    return readFileFragment(fullMatch, fragmentFilename, syncFuncTemplateDir);
  }

  var docDefinitionDir = path.dirname(docDefinitionsFile);
  function readDocDefinitionFragment(fullMatch, fragmentFilename) {
    return readFileFragment(fullMatch, fragmentFilename, docDefinitionDir);
  }

  var syncFuncTemplatePath = syncFuncTemplateDir + '/sync-function-template.js';
  var syncFuncTemplate;
  try {
    syncFuncTemplate = fs.readFileSync(syncFuncTemplatePath, 'utf8');
  } catch (ex) {<commit_msg>Minor reorganization of sync-function-loader module code<commit_after>/**
 * Generates a complete sync function from the specified document definitions file.
 *
 * @param {string} docDefinitionsFile The path to the document definitions file
 *
 * @returns The full contents of the generated sync function as a string
 */
exports.load = loadFromFile;

var fs = require('fs');
var path = require('path');
var indent = require('../lib/indent.js/indent.min.js');

function loadFromFile(docDefinitionsFile) {
  var syncFuncTemplateDir = path.dirname(module.filename);

  function readSyncFunctionFragment(fullMatch, fragmentFilename) {
    return readFileFragment(fullMatch, fragmentFilename, syncFuncTemplateDir);
  }

  var docDefinitionDir = path.dirname(docDefinitionsFile);
  function readDocDefinitionFragment(fullMatch, fragmentFilename) {
    return readFileFragment(fullMatch, fragmentFilename, docDefinitionDir);
  }

  var syncFuncTemplatePath = syncFuncTemplateDir + '/sync-function-template.js';
  var syncFuncTemplate;
  try {
    syncFuncTemplate = fs.readFileSync(syncFuncTemplatePath, 'utf8');
  } catch (ex) {
{'fraction_non_alphanumeric': 0.09474161378059837, 'fraction_numerical': 0.0009066183136899365, 'mean_word_length': 5.568452380952381, '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': '1975985', 'n_tokens_mistral': 585, 'n_tokens_neox': 570, 'n_words': 163}