<commit_before># Contains new methods to extend the native Hash class with extra functionality.
#
# @author <NAME> <<EMAIL>>
#
class Hash

# Will merge a hash, merging all nested hashes instead of replacing the original.
# In place version of recursiveMerge
#
# @param       (see #recursiveMerge)
# @return      (see #recursiveMerge)
#
def recursiveMerge!( override )

	self.merge! override do |key, a, b|

		a.is_a?( Hash ) && b.is_a?( Hash ) ? a.recursiveMerge!( b ) : b

	end

	self

end

# Will merge a hash, merging all nested hashes instead of replacing the original.
#
# @param       override [Hash] The hash from which to take overriding values.
# @return               [Hash] a duplicate of self with values overriden from override.
#
def recursiveMerge( override )

	target = dup
	target.recursiveMerge!( override )

end


# from: https://stackoverflow.com/a/1820492/1115652
#
#
def dig( *path )

  path.inject( self ) do | location, key |

    location.respond_to?( :keys ) ? location[ key ] : nil

  end

end


end # class Hash<commit_msg>Comments and whitespace improvements to Hash<commit_after># Contains new methods to extend the native Hash class with extra functionality.
#
# @author <NAME> <<EMAIL>>
#
class Hash

# Will merge a hash, merging all nested hashes instead of replacing the original.
# In place version of recursiveMerge
#
# @param       (see #recursiveMerge)
# @return      (see #recursiveMerge)
#
def recursiveMerge!( override )

	self.merge! override do |key, a, b|

		a.is_a?( Hash ) && b.is_a?( Hash ) ? a.recursiveMerge!( b ) : b

	end

	self

end

# Will merge a hash, merging all nested hashes instead of replacing the original.
#
# @param  override [Hash] The hash from which to take overriding values.
# @return          [Hash] a duplicate of self with values overriden from override.
#
def recursiveMerge( override )

	target = dup
	target.recursiveMerge!( override )

end


# Searches in nested hashes for a certain path.
#
# @param  path [HashKey, ...] A comma separated list of hash keys.
# @return      [HashValue]    The value of the path requested or nil if it doesn't exist.
#
# @example Usage
#   people  = { anna: { children: { kenny: { hobbies: dancing }, bibi: { age: 12 } } } }
#   age     = people.dig( :anna, :children, :bibi, :age     ) => 12
#   hobbies = people.dig( :anna, :children, :bibi, :hobbies ) => nil
#
# from: https://stackoverflow.com/a/1820492/1115652
#
def dig( *path )

  path.reduce( self ) do | location, key |

    location.respond_to?( :keys ) ? location[ key ] : nil

  end

end


end # class Hash
{'fraction_non_alphanumeric': 0.11029126213592233, 'fraction_numerical': 0.012427184466019418, 'mean_word_length': 3.3513513513513513, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '1515361', 'n_tokens_mistral': 873, 'n_tokens_neox': 805, 'n_words': 309}