<commit_before>module Unit
  include Comparable
  
  class NormalizeError < RuntimeError; end
  class ConversionError < RuntimeError; end
  
  # Public API of a Unit
  class Unit < Numeric
    # Rounding precision for comparing two units
    EQUALITY_PRECISION = 5
    
    @normalization_factor = nil
    @base_unit = nil
    
    attr_accessor   :value
    attr_reader     :normalized_value, :base_unit
    
    delegate :to_i, :to_f, :to_d, :ceil, :floor, :round, :abs, to: :value
    
    def self.[](arg)
      new(arg)
    end
    
    def self.definition
      I18n.t("unit.#{self.unit_name}.definition", default: 'Undefined').gsub("\n",'')
    end
    
    def self.normalization_factor
      @normalization_factor
    end
    
    def self.available_units
      subclasses
    end
    
    def self.available_unit_types
      available_units.map{|c| c.name.split('::').last.underscore.singularize}
    end
    
    def initialize(arg)
      if arg.is_a? Hash
        @normalized_value = arg[:normalized]
        @value = denormalize_value
      elsif arg.class.superclass == self.class.superclass
        @normalized_value = arg.normalized_value
        @value = denormalize_value
      else
        @value = arg
        @normalized_value = normalize_value
      end
    end
    
    def +(other)
      if other.class.superclass == self.class.superclass
        self.class.new(normalized: self.normalized_value + other.normalized_value)
      else
        self.class.new(self.value + other)
      end
    end
    
    def -(other)
      if other.class.superclass == self.class.superclass
        self.class.new(normalized: self.normalized_value - other.normalized_value)
      else
        self.class.new(self.value - other)<commit_msg>Add some definitions to the translations file<commit_after>module Unit
  include Comparable
  
  class NormalizeError < RuntimeError; end
  class ConversionError < RuntimeError; end
  
  # Public API of a Unit
  class Unit < Numeric
    # Rounding precision for comparing two units
    EQUALITY_PRECISION = 5
    
    @normalization_factor = nil
    @base_unit = nil
    
    attr_accessor   :value
    attr_reader     :normalized_value, :base_unit
    
    delegate :to_i, :to_f, :to_d, :ceil, :floor, :round, :abs, to: :value
    
    def self.[](arg)
      new(arg)
    end
    
    def self.definition
      I18n.t("unit.#{self.unit_name}.definition", default: 'Undefined').gsub("\n",'')
    end
    
    def self.normalization_factor
      @normalization_factor
    end
    
    def self.available_units
      subclasses
    end
    
    def self.available_unit_types
      available_units.map{|c| c.name.split('::').last.underscore.singularize}
    end
    
    def initialize(arg)
      if arg.is_a? Hash
        @normalized_value = arg[:normalized]
        @value = denormalize_value
      elsif arg.class.superclass == self.class.superclass
        @normalized_value = arg.normalized_value
        @value = denormalize_value
      else
        @value = arg.to_f
        @normalized_value = normalize_value
      end
    end
    
    def +(other)
      if other.class.superclass == self.class.superclass
        self.class.new(normalized: self.normalized_value + other.normalized_value)
      else
        self.class.new(self.value + other)
      end
    end
    
    def -(other)
      if other.class.superclass == self.class.superclass
        self.class.new(normalized: self.normalized_value - other.normalized_value)
      else
        self.class.new(self.value - other)
{'fraction_non_alphanumeric': 0.09044513751063227, 'fraction_numerical': 0.001701162461015027, 'mean_word_length': 2.4054054054054053, 'pattern_counts': {'":': 0, '<': 9, '<?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': '628536', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1105, 'n_words': 239}