<commit_before>require 'ostruct'

class DeepOpenStruct
  def self.load(item)
    raise ArgumentError, "DeepOpenStruct must be passed a Hash or Array" unless(item.is_a?(Hash) || item.is_a?(Array))
    item = item.clone
    if(item.is_a?(Hash))
      item.merge!(item) do |key, value, oldvalue|
        if(value.is_a?(Hash) || value.is_a?(Array))
          DeepOpenStruct.load(value)
        else
          value
        end
      end
      return OpenStruct.new(item)
    elsif(item.is_a?(Array))
      return item.map do |value|
        if(value.is_a?(Hash) || value.is_a?(Array))
          DeepOpenStruct.load(value)
        else
          value
        end
      end
    end
  end
end<commit_msg>Removed item.clone in favor of better design<commit_after>require 'ostruct'

class DeepOpenStruct
  def self.load(item)
    raise ArgumentError, "DeepOpenStruct must be passed a Hash or Array" unless(item.is_a?(Hash) || item.is_a?(Array))
    if(item.is_a?(Hash))
      item = item.merge(item) do |key, value, oldvalue|
        if(value.is_a?(Hash) || value.is_a?(Array))
          DeepOpenStruct.load(value)
        else
          value
        end
      end
      return OpenStruct.new(item)
    elsif(item.is_a?(Array))
      return item.map do |value|
        if(value.is_a?(Hash) || value.is_a?(Array))
          DeepOpenStruct.load(value)
        else
          value
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11410347271438696, 'fraction_numerical': 0.0, 'mean_word_length': 2.330188679245283, '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': '4972149', 'n_tokens_mistral': 461, 'n_tokens_neox': 476, 'n_words': 104}