<commit_before>const defaultsDeep = require('lodash.defaultsdeep');
const lodashClone = require('lodash.clone');
const lodashMerge = require('lodash.merge');
const Defaults = require('./defaults.js');
const Utils = require('../util/utils.js');
const Logger = require('../util/logger.js');

class Settings {

  static get DEFAULT_ENV() {
    return 'default';
  }

  static get DEFAULTS() {
    return Defaults;
  }

  static parse(settings = {}, baseSettings = {}, argv = {}, testEnv = null) {
    let instanceSettings = new Settings(baseSettings, argv);
    instanceSettings.init(testEnv, settings);

    return instanceSettings.settings;
  }

  constructor(baseSettings = null, argv = {}) {
    this.baseSettings = baseSettings || {};
    this.argv = argv;
    this.testEnv = null;

    let defaults = lodashClone(Settings.DEFAULTS, true);
    this.settings = Object.assign({}, defaults);

    // copy all other properties outside the "test_settings" environments
    Object.keys(this.baseSettings).forEach(key => {
      if (key === 'test_settings') {
        return;
      }

      let copyVal = lodashClone(this.baseSettings[key], true);

      if (Utils.isObject(this.settings[key])) {
        Object.assign(this.settings[key], copyVal);
      } else {
        this.settings[key] = copyVal;
      }
    });
  }
<commit_msg>fixed unit tests<commit_after>const defaultsDeep = require('lodash.defaultsdeep');
const lodashClone = require('lodash.clone');
const lodashMerge = require('lodash.merge');
const Defaults = require('./defaults.js');
const Utils = require('../util/utils.js');
const Logger = require('../util/logger.js');

class Settings {

  static get DEFAULT_ENV() {
    return 'default';
  }

  static get DEFAULTS() {
    return Defaults;
  }

  static parse(settings = {}, baseSettings = {}, argv = {}, testEnv = null) {
    let instanceSettings = new Settings(baseSettings, argv);
    instanceSettings.init(testEnv, settings);

    return instanceSettings.settings;
  }

  constructor(baseSettings = null, argv = {}) {
    this.baseSettings = baseSettings || {};
    this.argv = argv;
    this.testEnv = '';

    let defaults = lodashClone(Settings.DEFAULTS, true);
    this.settings = Object.assign({}, defaults);

    // copy all other properties outside the "test_settings" environments
    Object.keys(this.baseSettings).forEach(key => {
      if (key === 'test_settings') {
        return;
      }

      let copyVal = lodashClone(this.baseSettings[key], true);

      if (Utils.isObject(this.settings[key])) {
        Object.assign(this.settings[key], copyVal);
      } else {
        this.settings[key] = copyVal;
      }
    });
  }

{'fraction_non_alphanumeric': 0.14591951861602107, 'fraction_numerical': 0.0, 'mean_word_length': 3.353518821603928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2816499', 'n_tokens_mistral': 784, 'n_tokens_neox': 771, 'n_words': 171}