<commit_before>module GettextColumnMapping

  class Mapper
    attr_accessor :mappings
    delegate :[], :has_key?, :to => :mappings, :allow_nil => true

    def translate_class_name?(obj)
      ! self[obj.name.underscore][:class_name].blank?
    end

    def map_attribute(obj,key)
      self[obj.name.underscore][:column_names][key]
    end

    def translate_key?(obj,key)
      begin
        self.has_key?(obj.name.underscore) && ! self[obj.name.underscore][:column_names][key].blank?
      rescue
        false
      end
    end

    def column_translation_for_attribute(obj,key)
      if has_translation_key?(obj,key)
        "#{obj.to_s_with_gettext}|#{map_attribute(obj,key)}"
      else
        "#{obj.to_s_with_gettext}|#{key.to_s.humanize}"
      end
    end

    def to_s_with_gettext(obj)
      array = [GettextColumnMapping.config.model_prefix]
      if  translate_class_name?(obj)
        array += self[obj.name.underscore][:class_name].to_s.split('|').collect(&:humanize).collect{|s| s.split(/\s+/).collect(&:humanize).join(' ')}
      else
        array += [obj.to_s_with_gettext_without_translation]
      end
      array.join('|')
    end

  end

end<commit_msg>Fix mapper API methods naming<commit_after>module GettextColumnMapping

  class Mapper
    attr_accessor :mappings
    delegate :[], :has_key?, :to => :mappings, :allow_nil => true


    def class_mapping(obj)
      self[obj.name.underscore][:class_name] || obj.name.underscore
    end

    def translate_class_name?(obj)
      ! self[obj.name.underscore][:class_name].blank?
    end

    def map_attribute(obj,key)
      self[obj.name.underscore][:column_names][key]
    end

    def translate_key?(obj,key)
      begin
        self.has_key?(obj.name.underscore) && ! self[obj.name.underscore][:column_names][key].blank?
      rescue
        false
      end
    end

    def column_translation_for_attribute(obj,key)
      if translate_key?(obj,key)
        "#{obj.to_s_with_gettext}|#{map_attribute(obj,key)}"
      else
        "#{obj.to_s_with_gettext}|#{key.to_s.humanize}"
      end
    end

    def to_s_with_gettext(obj)
      array = [GettextColumnMapping.config.model_prefix]
      if  translate_class_name?(obj)
        array += self[obj.name.underscore][:class_name].to_s.split('|').collect(&:humanize).collect{|s| s.split(/\s+/).collect(&:humanize).join(' ')}
      else
        array += [obj.to_s_with_gettext_without_translation]
      end
      array.join('|')
    end

  end

end
{'fraction_non_alphanumeric': 0.13766653209527654, 'fraction_numerical': 0.0, 'mean_word_length': 3.164705882352941, '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': '1349312', 'n_tokens_mistral': 876, 'n_tokens_neox': 864, 'n_words': 118}