<commit_before>#
# ConfigSpace - A tree-structured configuration system.
#

# We need this for marshalling.
require 'yaml'

# Module for booleans. User types must support a 'from_str' similar to this.
# Note we interpret 'nil' as true, since this is often used for boolean flags,
# in which case the user typing 'set flag' means to turn it on.
module Boolean
  def Boolean.from_str(thing)
    if thing.nil?
      true
    elsif !thing or thing.kind_of?(TrueClass)
      !!thing
    elsif thing.kind_of?(Integer)
      thing != 0
    elsif thing.kind_of?(String)
      case thing.downcase
      when 'no', 'off', '0', 'false', '-', 'disabled': false<commit_msg>Define YAML.load_file if it doesn't exist<commit_after>#
# ConfigSpace - A tree-structured configuration system.
#

# We need this for marshalling.
require 'yaml'

module YAML
  class << self
    unless method_defined? :load_file
      def load_file(file)
        YAML.load(File.read(file))
      end
    end
  end
end

# Module for booleans. User types must support a 'from_str' similar to this.
# Note we interpret 'nil' as true, since this is often used for boolean flags,
# in which case the user typing 'set flag' means to turn it on.
module Boolean
  def Boolean.from_str(thing)
    if thing.nil?
      true
    elsif !thing or thing.kind_of?(TrueClass)
      !!thing
    elsif thing.kind_of?(Integer)
      thing != 0
    elsif thing.kind_of?(String)
      case thing.downcase
      when 'no', 'off', '0', 'false', '-', 'disabled': false
{'fraction_non_alphanumeric': 0.10106382978723404, 'fraction_numerical': 0.0026595744680851063, 'mean_word_length': 3.1922005571030643, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7118777', 'n_tokens_mistral': 477, 'n_tokens_neox': 471, 'n_words': 176}