<commit_before>module BrighterPlanet
  module Emitter
    REQUIRED_COMPONENTS = %w{
      carbon_model
      characterization
      data summarization
      relationships
    }
    def included(base)
      base.extend ClassMethods
      
      common_name = self.to_s.split('::').last.underscore
      common_camel = common_name.camelcase

      REQUIRED_COMPONENTS.each do |component|
        require "#{common_name}/#{component}"
      end
      
      base.instance_variable_set :@emission_scope, @emission_scope if @emission_scope
      
      require 'leap'
      require 'cohort_scope'
      base.extend ::Leap::Subject
      base.send :include, "::BrighterPlanet::#{common_camel}::CarbonModel".constantize

      require 'charisma'
      base.send :include, ::Charisma
      base.send :include, "::BrighterPlanet::#{common_camel}::Characterization".constantize
      base.add_implicit_characteristics

      require 'data_miner'
      base.send :include, "::BrighterPlanet::#{common_camel}::Data".constantize

      require 'summary_judgement'
      base.extend ::SummaryJudgement
      base.send :include, "::BrighterPlanet::#{common_camel}::Summarization".constantize

      require 'falls_back_on'
      begin
        require "#{common_name}/fallback"
        base.send :include, "::BrighterPlanet::#{common_camel}::Fallback".constantize
      rescue ::LoadError
        # not required
      end

      base.send :include, "::BrighterPlanet::#{common_camel}::Relationships".constantize
    end
        
    def scope(statement)
      @emission_scope = statement
    end
    
    module ClassMethods
      def add_implicit_characteristics
        decisions[:emission].committees.map(&:name).reject { |c| characteristics.keys.unshift(:emission).include? c }.each do |c|
          characterize { has c }
        end
      end
      
      def emission_scope; @emission_scope end
    end
  end
end<commit_msg>implicit characteristics<commit_after>require 'leap'
require 'cohort_scope'
require 'charisma'
require 'data_miner'
require 'summary_judgement'
require 'falls_back_on'

module BrighterPlanet
  module Emitter
    REQUIRED_COMPONENTS = %w{
      carbon_model
      characterization
      data summarization
      relationships
    }
    
    def included(base)
      base.extend ClassMethods
      
      common_name = self.to_s.split('::').last.underscore
      common_camel = common_name.camelcase

      REQUIRED_COMPONENTS.each do |component|
        require "#{common_name}/#{component}"
      end
      
      base.instance_variable_set :@emission_scope, @emission_scope if @emission_scope
      
      base.extend ::Leap::Subject
      base.send :include, "::BrighterPlanet::#{common_camel}::CarbonModel".constantize

      base.send :include, ::Charisma
      base.send :include, "::BrighterPlanet::#{common_camel}::Characterization".constantize
      base._add_emission_characteristic
      base._add_implicit_characteristics

      base.send :include, "::BrighterPlanet::#{common_camel}::Data".constantize

      base.extend ::SummaryJudgement
      base.send :include, "::BrighterPlanet::#{common_camel}::Summarization".constantize

      begin
        require "#{common_name}/fallback"
        base.send :include, "::BrighterPlanet::#{common_camel}::Fallback".constantize
      rescue ::LoadError
        # not required
      end

      base.send :include, "::BrighterPlanet::#{common_camel}::Relationships".constantize
    end
        
    def scope(statement)
      @emission_scope = statement
    end
    
    class CarbonEmission < ::Charisma::Measurement
      units :kilograms => 'kg CO2e'
    end
    
    module ClassMethods
      def _add_implicit_characteristics
        preexisting = characteristics.keys
        decisions[:emission].committees.reject do |committee|
          preexisting.include? committee.name
        end.each do |committee|
          characterize do
            has committee.name, :options => committee.options.slice(:measures, :display_with)
          end
        end
      end
      
      def _add_emission_characteristic
        characterize do
          has :emission, :options => { :measures => CarbonEmission }
        end        
      end
      
      def emission_scope; @emission_scope end
    end
  end
end
{'fraction_non_alphanumeric': 0.09775491113189898, 'fraction_numerical': 0.00023386342376052386, 'mean_word_length': 2.909506398537477, 'pattern_counts': {'":': 12, '<': 4, '<?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': '711675', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1246, 'n_words': 238}