<commit_before># stolen from ActiveSupport

class Object
  # Don't override already defined or aliased methods
  #
  def safe_def(name,&blk)
    unless method_defined?(name.to_sym)
      self.send(:define_method,name, &blk)
    end
  end

  def safe_alias(new_method, orig_method)
    unless method_defined?(new_method.to_sym)
      alias_method(new_method, orig_method)
    end
  end

  safe_def(:blank?) do
    respond_to?(:empty?) ? empty? : !self
  end

  safe_def(:present?) do
    !blank?
  end

  safe_def(:presence) do
    self if present?
  end
end

class NilClass
  safe_def(:blank?) do
    true
  end
end

class FalseClass
  safe_def(:blank?) do
    true
  end
end

class TrueClass
  safe_def(:blank?) do
    false
  end
end

class Array
  safe_alias(:blank?, :empty?)
end

class Hash
  safe_alias(:blank?, :empty?)
end

class String
  safe_def(:blank?) do
    self !~ /[^[:space:]]/
  end
end

class Numeric
  safe_def(:blank?) do
    false
  end
end<commit_msg>don't pollute global namespace with blank? thanks to @grosser for suggestion<commit_after># stolen from ActiveSupport

class Object
  unless method_defined?(:blank?)
    def blank?
      respond_to?(:empty?) ? empty? : !self
    end
  end

  unless method_defined?(:present?)
    def present?
      !blank?
    end
  end

  unless method_defined?(:presence)
    def presence
      self if present?
    end
  end
end

class NilClass
  unless method_defined?(:blank?)
    def blank?
      true
    end
  end
end

class FalseClass
  unless method_defined?(:blank?)
    def blank?
      true
    end
  end
end

class TrueClass
  unless method_defined?(:blank?)
    def blank?
      false
    end
  end
end

class Array
  unless method_defined?(:blank?)
    alias_method :blank?, :empty?
  end
end

class Hash
  unless method_defined?(:blank?)
    alias_method :blank?, :empty?
  end
end

class String
  unless method_defined?(:blank?)
    def blank?
      self !~ /[^[:space:]]/
    end
  end
end

class Numeric
  unless method_defined?(:blank?)
    def blank?
      false
    end
  end
end
{'fraction_non_alphanumeric': 0.09514563106796116, 'fraction_numerical': 0.0, 'mean_word_length': 3.0570866141732282, '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': '3200516', 'n_tokens_mistral': 704, 'n_tokens_neox': 693, 'n_words': 203}