<commit_before>class DutyExpressionFormatter

  def self.prettify(float)
    float.to_i == float ? float.to_i : float
  end

  def self.format(opts={})
    duty_expression_id = opts[:duty_expression_id]
    duty_expression_description = opts[:duty_expression_description]
    duty_amount = opts[:duty_amount]
    monetary_unit = opts[:monetary_unit]
    measurement_unit = opts[:measurement_unit]
    measurement_unit_qualifier = opts[:measurement_unit_qualifier]
    

    @formatted = ""
    case duty_expression_id
    when "99"
      @formatted << measurement_unit
    else
      if duty_amount.present?
        @formatted << prettify(duty_amount).to_s
      end
      # should use the abbreviation here first
      if duty_expression_description.present? && !monetary_unit.present?
        @formatted << " " << duty_expression_description
      end
      if monetary_unit.present?
        @formatted << " " << monetary_unit
      end
      if measurement_unit.present?
        @formatted << " / " << measurement_unit
      end
      if measurement_unit_qualifier.present?
        @formatted << " " << measurement_unit_qualifier
      end
    end
    @formatted
  end
end
<commit_msg>properly wrap the measurement unit with its qualifier<commit_after>class DutyExpressionFormatter

  def self.prettify(float)
    float.to_i == float ? float.to_i : float
  end

  def self.format(opts={})
    duty_expression_id = opts[:duty_expression_id]
    duty_expression_description = opts[:duty_expression_description]
    duty_amount = opts[:duty_amount]
    monetary_unit = opts[:monetary_unit]
    measurement_unit = opts[:measurement_unit]
    measurement_unit_qualifier = opts[:measurement_unit_qualifier]
    

    @formatted = ""
    case duty_expression_id
    when "99"
      @formatted << measurement_unit
    else
      if duty_amount.present?
        @formatted << prettify(duty_amount).to_s
      end
      # should use the abbreviation here first
      if duty_expression_description.present? && !monetary_unit.present?
        @formatted << " " << duty_expression_description
      end
      if monetary_unit.present?
        @formatted << " #{monetary_unit}"
      end
      if measurement_unit.present? && measurement_unit_qualifier.present?
        @formatted << " / (#{measurement_unit}/#{measurement_unit_qualifier})"
      elsif measurement_unit.present?
        @formatted << " / #{measurement_unit}"
      end
    end
    @formatted
  end
end

{'fraction_non_alphanumeric': 0.08946726311508743, 'fraction_numerical': 0.0016266775111834079, 'mean_word_length': 3.2195540308747854, 'pattern_counts': {'":': 0, '<': 37, '<?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': '3302453', 'n_tokens_mistral': 747, 'n_tokens_neox': 725, 'n_words': 141}