<commit_before># encoding: utf-8

class Object
  def vacant?
    self.nil? || 
    self.respond_to?(:strip) && self.strip.empty? ||
    self.respond_to?(:zero?) && self.zero? ||
    Array === self && (self  - [nil]).empty? 
  end
end

unless Hash.respond_to? take
  class Hash
    def take count, from = 0
      Hash[self.to_a[from..from+count]]
    end
  end
end

unless Array.respond_to? to_h
  class Array
    def to_h
      i = 0
      self.inject({}) { |memo, e|
        raise TypeError.new("wrong element type #{e.class} at #{i} (expected array)") unless Array === e
        raise ArgumentError.new("wrong array length at #{i} (expected 2, was #{e.count})") unless e.count == 2
        
        i += 1
        memo[e.first] = e.last
        memo
      }
    end
  end<commit_msg>Fixed (backported Array.to_h) for 2.0.0.<commit_after># encoding: utf-8

class Object
  def vacant?
    self.nil? || 
    self.respond_to?(:strip) && self.strip.empty? ||
    self.respond_to?(:zero?) && self.zero? ||
    Array === self && (self  - [nil]).empty? 
  end
end

unless Hash.respond_to? :take
  class Hash
    def take count, from = 0
      Hash[self.to_a[from..from+count]]
    end
  end
end

unless Array.respond_to? :to_h
  class Array
    def to_h
      i = 0
      self.inject({}) { |memo, e|
        raise TypeError.new("wrong element type #{e.class} at #{i} (expected array)") unless Array === e
        raise ArgumentError.new("wrong array length at #{i} (expected 2, was #{e.count})") unless e.count == 2
        
        i += 1
        memo[e.first] = e.last
        memo
      }
    end
  end
{'fraction_non_alphanumeric': 0.14759224515322075, 'fraction_numerical': 0.009380863039399626, 'mean_word_length': 2.3264033264033266, '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': '1857192', 'n_tokens_mistral': 576, 'n_tokens_neox': 553, 'n_words': 155}