<commit_before>module HashHelpers
  class << self
    def deep_symbolize_keys(hash)
      deep_transform_keys(hash){ |key| key.to_sym rescue key }
    end

    def deep_transform_keys(hash, &block)
      result = {}
      hash.each do |key, value|
        result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value
      end
      result
    end
  end
end
<commit_msg>HashHelpers is a submodule of Prmd<commit_after># :nodoc:
module Prmd
  module HashHelpers
    def self.deep_symbolize_keys(hash)
      deep_transform_keys(hash) do |key|
        if key.respond_to?(:to_sym)
          key.to_sym
        else
          key
        end
      end
    end

    def self.deep_transform_keys(hash, &block)
      result = {}
      hash.each do |key, value|
        new_key = yield(key)
        new_value = value
        new_value = deep_transform_keys(value, &block) if value.is_a?(Hash)
        result[new_key] = new_value
      end
      result
    end
  end
end

{'fraction_non_alphanumeric': 0.08841463414634146, 'fraction_numerical': 0.0, 'mean_word_length': 2.361774744027304, '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': '6780923', 'n_tokens_mistral': 330, 'n_tokens_neox': 331, 'n_words': 78}