<commit_before>class Unit < Numeric

  # Handle the definition of units
  class Definition
    
    # @return [Array]
    attr_writer :aliases
    
    # @return [Symbol]
    attr_accessor :kind
    
    # @return [Numeric]
    attr_accessor :scalar
    
    # @return [Array]
    attr_accessor :numerator

    # @return [Array]
    attr_accessor :denominator
    
    # @return [String]
    attr_accessor :display_name
    
    # @example Raw definition from a hash
    #   Unit::Definition.new("rack-unit",[%w{U rack-U}, (6405920109971793/144115188075855872), :length, %w{<meter>} ])
    # 
    # @example Block form
    #   Unit::Definition.new("rack-unit") do |unit|
    #     unit.aliases = %w{U rack-U}
    #     unit.definition = Unit("7/4 inches")
    #   end
    #
    def initialize(_name, _definition = [], &block)
      yield self if block_given?
      self.name     ||= _name.gsub(/[<>]/,'')
      @aliases      ||= _definition[0]
      @scalar       ||= _definition[1]
      @kind         ||= _definition[2]
      @numerator    ||= _definition[3] || Unit::UNITY_ARRAY
      @denominator  ||= _definition[4] || Unit::UNITY_ARRAY
      @display_name ||= @aliases.first
    end
    
    # name of the unit
    # nil if name is not set, adds '<' and '>' around the name
    # @return [String, nil]
    # @todo refactor Unit and Unit::Definition so we don't need to wrap units with angle brackets
    def name
      "<#{@name}>" if (defined?(@name) && @name)
    end
    
    # set the name, strip off '<' and '>'
    # @param [String]
    # @return [String]
    def name=(_name)
      @name = _name.gsub(/[<>]/,'')
    end
    
    # alias array must contain the name of the unit and entries must be unique
    # @return [Array]
    def aliases
      [[@aliases], @name].flatten.compact.uniq<commit_msg>definitions will default to using the unit name if no aliases are provided<commit_after>class Unit < Numeric

  # Handle the definition of units
  class Definition
    
    # @return [Array]
    attr_writer :aliases
    
    # @return [Symbol]
    attr_accessor :kind
    
    # @return [Numeric]
    attr_accessor :scalar
    
    # @return [Array]
    attr_accessor :numerator

    # @return [Array]
    attr_accessor :denominator
    
    # @return [String]
    attr_accessor :display_name
    
    # @example Raw definition from a hash
    #   Unit::Definition.new("rack-unit",[%w{U rack-U}, (6405920109971793/144115188075855872), :length, %w{<meter>} ])
    # 
    # @example Block form
    #   Unit::Definition.new("rack-unit") do |unit|
    #     unit.aliases = %w{U rack-U}
    #     unit.definition = Unit("7/4 inches")
    #   end
    #
    def initialize(_name, _definition = [], &block)
      yield self if block_given?
      self.name     ||= _name.gsub(/[<>]/,'')
      @aliases      ||= (_definition[0] || [_name])
      @scalar       ||= _definition[1]
      @kind         ||= _definition[2]
      @numerator    ||= _definition[3] || Unit::UNITY_ARRAY
      @denominator  ||= _definition[4] || Unit::UNITY_ARRAY
      @display_name ||= @aliases.first
    end
    
    # name of the unit
    # nil if name is not set, adds '<' and '>' around the name
    # @return [String, nil]
    # @todo refactor Unit and Unit::Definition so we don't need to wrap units with angle brackets
    def name
      "<#{@name}>" if (defined?(@name) && @name)
    end
    
    # set the name, strip off '<' and '>'
    # @param [String]
    # @return [String]
    def name=(_name)
      @name = _name.gsub(/[<>]/,'')
    end
    
    # alias array must contain the name of the unit and entries must be unique
    # @return [Array]
    def aliases
      [[@aliases], @name].flatten.compact.uniq
{'fraction_non_alphanumeric': 0.1362162162162162, 'fraction_numerical': 0.02216216216216216, 'mean_word_length': 2.436397400185701, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '6585217', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1222, 'n_words': 328}