<commit_before>require 'yaml'
require_relative 'environment'

module Config
  module Factory
    module Environments
      DEFAULT_ENVIRONMENT = :production
      STANDARD_ENVIRONMENTS = [:defaults, :development, :test, :stage, :staging, :production].freeze

      def self.load_file(path)
        hash = YAML.load_file(path)
        load_hash(hash)
      end

      def self.load_hash(hash)
        if Environments::STANDARD_ENVIRONMENTS.any? { |k| hash.key?(k.to_s) }
          hash.map do |k, v|
            k2 = k.to_sym
            [k2, Environment.new(name: k2, configs: v)]
          end.to_h
        else
          Environment.new(name: Environments::DEFAULT_ENVIRONMENT, configs: hash)
        end
      end
    end
  end
end
<commit_msg>Added TODO<commit_after>require 'yaml'
require_relative 'environment'

module Config
  module Factory
    module Environments
      DEFAULT_ENVIRONMENT = :production
      STANDARD_ENVIRONMENTS = [:defaults, :development, :test, :stage, :staging, :production].freeze

      def self.load_file(path)
        hash = YAML.load_file(path)
        load_hash(hash)
      end

      # TODO: separate array and single-environment loading
      def self.load_hash(hash)
        if Environments::STANDARD_ENVIRONMENTS.any? { |k| hash.key?(k.to_s) }
          hash.map do |k, v|
            k2 = k.to_sym
            [k2, Environment.new(name: k2, configs: v)]
          end.to_h
        else
          Environment.new(name: Environments::DEFAULT_ENVIRONMENT, configs: hash)
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09606705351386202, 'fraction_numerical': 0.0038684719535783366, 'mean_word_length': 2.4642857142857144, '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': '5506099', 'n_tokens_mistral': 518, 'n_tokens_neox': 497, 'n_words': 113}