<commit_before>module URI
  ##
  # Extends a hash with query string reordering/deleting capabilities
  module QueryHash
    def ordered_query_string(*args)
      unmentioned_keys = keys.reject { |key| args.include?(key.to_s) || args.include?(key.to_sym) }
      (
        args.uniq.map { |key| render_value(key, self[key]) }.reject { |i| i.nil? } +
            unmentioned_keys.collect { |key| render_value(key, self[key]) }
      ).join('&')
    end

    def delete_keys(*args)
      args.uniq.map { |key| delete(key.to_s) }
      to_s
    end

    def [](key)
      item = super key
      item = super(key.to_s) if item.nil? || item.length == 0
      item.class == Array && item.length == 0 ? nil : item
    end

    def to_s
      keys.map { |key| render_value(key, self[key]) }.join('&')
    end

    private

    def render_value(key, value)
      return nil if value.nil?
      return value.map { |el| render_value(key, el) }.join('&') if value.kind_of? Array
      "#{key}=#{CGI::escape(value)}"
    end
  end
end<commit_msg>Stop using #collect, really this time<commit_after>module URI
  ##
  # Extends a hash with query string reordering/deleting capabilities
  module QueryHash
    def ordered_query_string(*args)
      unmentioned_keys = keys.reject { |key| args.include?(key.to_s) || args.include?(key.to_sym) }
      (
        args.uniq.map { |key| render_value(key, self[key]) }.reject { |i| i.nil? } +
            unmentioned_keys.map { |key| render_value(key, self[key]) }
      ).join('&')
    end

    def delete_keys(*args)
      args.uniq.map { |key| delete(key.to_s) }
      to_s
    end

    def [](key)
      item = super key
      item = super(key.to_s) if item.nil? || item.length == 0
      item.class == Array && item.length == 0 ? nil : item
    end

    def to_s
      keys.map { |key| render_value(key, self[key]) }.join('&')
    end

    private

    def render_value(key, value)
      return nil if value.nil?
      return value.map { |el| render_value(key, el) }.join('&') if value.kind_of? Array
      "#{key}=#{CGI::escape(value)}"
    end
  end
end
{'fraction_non_alphanumeric': 0.14779270633397312, 'fraction_numerical': 0.0019193857965451055, 'mean_word_length': 2.6072664359861593, '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': '3267745', 'n_tokens_mistral': 746, 'n_tokens_neox': 733, 'n_words': 176}