<commit_before>module One9
  class ReportMethod
    CURRENT_DIRS = [Dir.pwd + '/', './']
    CURRENT_DIRS_REGEX = Regexp.new "^#{Regexp.union(CURRENT_DIRS)}"

    class <<self; attr_accessor :stacks; end

    def self.create(meths, stacks)
      self.stacks = stacks
      meths.map {|e| new(e) }
    end

    def initialize(meth)
      @meth = meth
    end

    [:name, :message, :type].each do |m|
      define_method(m) { @meth.send(m) }
    end

    def stacks
      self.class.stacks[name].map {|e| report_stack(e) }.compact.
        map {|e| e.sub(CURRENT_DIRS_REGEX, '') }.uniq
    end

    def count
      self.class.stacks[name].select {|e| report_stack(e) }.compact.uniq.size
    end

    def report_stack(ary)
      ary[0][regexp_paths] ? ary[0] : nil
    end

    def regexp_paths
      @regexp_paths ||= Regexp.new "^#{Regexp.union(report_paths)}"
    end

    def report_paths
      @report_paths ||= CURRENT_DIRS.map {|e| e + 'lib/' }
    end
  end
end
<commit_msg>count reflects number of unique stacks<commit_after>module One9
  class ReportMethod
    CURRENT_DIRS = [Dir.pwd + '/', './']
    CURRENT_DIRS_REGEX = Regexp.new "^#{Regexp.union(CURRENT_DIRS)}"

    class <<self; attr_accessor :stacks; end

    def self.create(meths, stacks)
      self.stacks = stacks
      meths.map {|e| new(e) }
    end

    def initialize(meth)
      @meth = meth
    end

    [:name, :message, :type].each do |m|
      define_method(m) { @meth.send(m) }
    end

    def stacks
      @stacks ||= self.class.stacks[name].map {|e| report_stack(e) }.
        compact.map {|e| e.sub(CURRENT_DIRS_REGEX, '') }.uniq
    end

    def count
      stacks.count
    end

    def report_stack(ary)
      ary[0][regexp_paths] ? ary[0] : nil
    end

    def regexp_paths
      @regexp_paths ||= Regexp.new "^#{Regexp.union(report_paths)}"
    end

    def report_paths
      @report_paths ||= CURRENT_DIRS.map {|e| e + 'lib/' }
    end
  end
end

{'fraction_non_alphanumeric': 0.14189886480908154, 'fraction_numerical': 0.0030959752321981426, 'mean_word_length': 2.5643382352941178, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3068904', 'n_tokens_mistral': 774, 'n_tokens_neox': 724, 'n_words': 154}