<commit_before>require 'std/core_ext/object'

class Hash
  # Has checks if target hash has all the data the other has, this is different
  # from #eql? which checks for complete matches.
  #
  # @param [Hash] other
  # @return [Boolean]
  #
  # @example
  #   hash = { a: 2, b: 3, c: 4 }
  #   slice1 = { a: 2, b: 3 }
  #   slice2 = { a: 2, c: 5 }
  #   hash.has_slice?(slice1) #=> true
  #   hash.has_slice?(slice2) #=> false
  def has_slice?(other)
    other.all? do |pair|
      key, value = *pair
      key?(key) && (self[key] == value)
    end
  end

  # Creates a new {Hash} from the provided keys, using the values from the
  # {Hash}. Unlike permit, slice will create a Hash with all the keys given.
  #
  # @param [Object] keys  keys to copy from the Hash
  # @return [Hash] hash slice
  def slice(*keys)
    keys.each_with_object({}) do |key, dest|
      dest[key] = self[key]
    end
  end

  # Similar to #values_of, uses #fetch instead to retrieve the values.
  #
  # @param [Object] keys
  # @return [Array<Object>] values from keys
  #
  # @example
  #   { a: 1, b: 2, c: 3 }.fetch_multi(:a, :b) #=> [1, 2]
  def fetch_multi(*keys)
    keys.map { |key| fetch(key) }
  end

  # Checks if the Hash has any content or not.
  #
  # @return [Boolean]<commit_msg>std: Hash#has_slice? give the parameter value left hand priority<commit_after>require 'std/core_ext/object'

class Hash
  # Has checks if target hash has all the data the other has, this is different
  # from #eql? which checks for complete matches.
  #
  # @param [Hash] other
  # @return [Boolean]
  #
  # @example
  #   hash = { a: 2, b: 3, c: 4 }
  #   slice1 = { a: 2, b: 3 }
  #   slice2 = { a: 2, c: 5 }
  #   hash.has_slice?(slice1) #=> true
  #   hash.has_slice?(slice2) #=> false
  def has_slice?(other)
    other.all? do |pair|
      key, value = *pair
      key?(key) && (value == self[key])
    end
  end

  # Creates a new {Hash} from the provided keys, using the values from the
  # {Hash}. Unlike permit, slice will create a Hash with all the keys given.
  #
  # @param [Object] keys  keys to copy from the Hash
  # @return [Hash] hash slice
  def slice(*keys)
    keys.each_with_object({}) do |key, dest|
      dest[key] = self[key]
    end
  end

  # Similar to #values_of, uses #fetch instead to retrieve the values.
  #
  # @param [Object] keys
  # @return [Array<Object>] values from keys
  #
  # @example
  #   { a: 1, b: 2, c: 3 }.fetch_multi(:a, :b) #=> [1, 2]
  def fetch_multi(*keys)
    keys.map { |key| fetch(key) }
  end

  # Checks if the Hash has any content or not.
  #
  # @return [Boolean]
{'fraction_non_alphanumeric': 0.13680154142581888, 'fraction_numerical': 0.01233140655105973, 'mean_word_length': 2.7677793904209, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2477628', 'n_tokens_mistral': 963, 'n_tokens_neox': 940, 'n_words': 329}