<commit_before>module MethodMap

  def dirty_map!(mapped = nil)
    @mapped = mapped || self
    map_method(:changes)
    map_method(:dirty?)
    map_method(:changed?)
    map_method(:clean_up!)
    map_method(/^([\w_]+)_changed\?$/, :changed?, true)
    map_method(/^([\w_]+)_change$/, :change, true)
    map_method(/^([\w_]+)_was$/, :was, true)
    map_method(/(^[\w_]+)=$/, :[]=)
    map_method(/(^[\w_]+)$/, :[], true)
  end

  def map_method(pattern, method_or_proc = nil, args = nil)
    regex = pattern.is_a?(Regexp) ? pattern : Regexp.new("^#{Regexp.escape(pattern.to_s)}$")
    method_map[regex] = {:method_or_proc => (method_or_proc || pattern), :args => args}
  end

  def method_missing(method, *args)
    if m = match_method(method)
      begin
        return @mapped.send *(m + args)
      rescue IndexError; end<commit_msg>Fixed incorrect regular expressions within dirty_map!<commit_after>module MethodMap

  def dirty_map!(mapped = nil)
    @mapped = mapped || self
    map_method(:changes)
    map_method(:dirty?)
    map_method(:changed?)
    map_method(:clean_up!)
    map_method(/^([\w_]+)_changed\?$/, :changed?, true)
    map_method(/^([\w_]+)_change$/, :change, true)
    map_method(/^([\w_]+)_was$/, :was, true)
    map_method(/^([\w_]+)=$/, :[]=)
    map_method(/^([\w_]+)$/, :[], true)
  end

  def map_method(pattern, method_or_proc = nil, args = nil)
    regex = pattern.is_a?(Regexp) ? pattern : Regexp.new("^#{Regexp.escape(pattern.to_s)}$")
    method_map[regex] = {:method_or_proc => (method_or_proc || pattern), :args => args}
  end

  def method_missing(method, *args)
    if m = match_method(method)
      begin
        return @mapped.send *(m + args)
      rescue IndexError; end
{'fraction_non_alphanumeric': 0.19405594405594406, 'fraction_numerical': 0.0, 'mean_word_length': 3.7694444444444444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4072860', 'n_tokens_mistral': 631, 'n_tokens_neox': 622, 'n_words': 116}