<commit_before>module TiyatrData
  class RecursiveOpenStruct
    # options:
    #   :exclude => [keys] - keys need to be symbols 
    def self.convert(hash, options = {})
      convert_hash_to_ostruct_recursive(hash, options) 
    end

    private

    def self.convert_hash_to_ostruct_recursive(hash, options)
      result = hash
      if result.is_a? Hash
        result = result
        result.each  do |key, val| 
          result[key] = convert_hash_to_ostruct_recursive(val, options) unless options[:exclude].try(:include?, key)
        end
        OpenStruct.new result       
      elsif result.is_a? Array
         result.map { |r| convert_hash_to_ostruct_recursive(r, options) }
      end
    end
  end
end<commit_msg>fixed bug in conversion of hash to open struct<commit_after>module TiyatrData
  class RecursiveOpenStruct
    # options:
    #   :exclude => [keys] - keys need to be symbols 
    def self.convert(hash, options = {})
      convert_hash_to_ostruct_recursive(hash, options) 
    end

    private

    def self.convert_hash_to_ostruct_recursive(hash, options)
      result = hash
      if result.is_a? Hash
        result.each  do |key, val| 
          result[key] = convert_hash_to_ostruct_recursive(val, options) unless options[:exclude].try(:include?, key)
        end
        OpenStruct.new result       
      elsif result.is_a? Array
        result.map { |r| convert_hash_to_ostruct_recursive(r, options) }
      else
        result
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07986577181208054, 'fraction_numerical': 0.0, 'mean_word_length': 2.610169491525424, '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': '2353050', 'n_tokens_mistral': 480, 'n_tokens_neox': 461, 'n_words': 113}