<commit_before>require 'yaml'


module ConfigContext
  
  class ConfigContextError < StandardError; end
  
  class << self

    def method_missing( method, *arguments, &block )
      
      @config ||= {}
      
      if( method =~/(.+)=$/)
        
        key           = method.to_s.delete( '=$' ).to_sym
        @config[key] = (arguments.length == 1) ? arguments[0] : arguments
      else
        
        return @config[method] if @config.keys.include?( method )
      end
    end
    
    def configure       
      yield self
    end

    def []( key )
      @config[key.to_sym] if @config
    end
    
    def[]=( key, value )
      @config[key.to_sym] = value if @config
    end
    
    def all
      @config
    end
  
    def load( config_file )

      @config ||= {}
      
      yaml_config = YAML.load_file( config_file )
      yaml_config.keys.each { |key| @config[key] = yaml_config[key] }
    rescue Exception => e
      raise ConfigContextError.new( e.message )
    else
      @config
    end
  end
end<commit_msg>Some errors related with inicializations<commit_after>require 'yaml'


module ConfigContext
  
  class ConfigContextError < StandardError; end
  
  class << self

    def method_missing( method, *arguments, &block )
      
      @config ||= {}
      
      if( method =~/(.+)=$/)
        
        key           = method.to_s.delete( '=$' ).to_sym
        @config[key] = (arguments.length == 1) ? arguments[0] : arguments
      else
        
        return @config[method] if @config.keys.include?( method )
      end
    end
    
    def configure       
      yield self
    end

    def []( key )

      @config ||= {}
      @config[key.to_sym] if @config
    end
    
    def[]=( key, value )

      @config ||= {}
      @config[key.to_sym] = value if @config
    end
    
    def all
      
      @config ||= {}
      @config
    end
  
    def load( config_file )

      @config ||= {}
      
      yaml_config = YAML.load_file( config_file )
      yaml_config.keys.each { |key| @config[key] = yaml_config[key] }
    rescue Exception => e
      raise ConfigContextError.new( e.message )
    else
      @config
    end
  end
end
{'fraction_non_alphanumeric': 0.11732101616628175, 'fraction_numerical': 0.0018475750577367205, 'mean_word_length': 1.7733674775928296, 'pattern_counts': {'":': 0, '<': 9, '<?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': '620517', 'n_tokens_mistral': 704, 'n_tokens_neox': 685, 'n_words': 164}