<commit_before>module GriffithCommon
  module FormattingHelpers
    def simple_number(val)
      return '-' if val.nil? || val.zero?
      val == val.to_i ? val.to_i : val.round(4)
    end

    def percentage(val, precision = 2)
      return '-' if val.nil? || val.zero?
      number_to_percentage(val * 100, precision: precision)
    end
    alias_method :decimal_to_percentage, :percentage

    def currency(val, unit: "", separator: ".", delimiter: ",", precision: 2)
      return '-' if val.nil? || val.zero?
      number_to_currency(val, unit: unit,
                              separator: separator,
                              delimiter: delimiter,
                              precision: precision)
    end

    def quantity(val)
      return '-' if val.nil? || val.zero?
      number_with_precision(val.to_f, precision: 2, delimiter: ',')
    end
  end
end<commit_msg>ensure that val is a number<commit_after>module GriffithCommon
  module FormattingHelpers
    def simple_number(val)
      return '-' if val.nil? || val.to_f.zero?
      val == val.to_i ? val.to_i : val.round(4)
    end

    def percentage(val, precision = 2)
      return '-' if val.nil? || val.to_f.zero?
      number_to_percentage(val * 100, precision: precision)
    end
    alias_method :decimal_to_percentage, :percentage

    def currency(val, unit: "", separator: ".", delimiter: ",", precision: 2)
      return '-' if val.nil? || val.to_f.zero?
      number_to_currency(val, unit: unit,
                              separator: separator,
                              delimiter: delimiter,
                              precision: precision)
    end

    def quantity(val)
      return '-' if val.nil? || val.zero?
      number_with_precision(val.to_f, precision: 2, delimiter: ',')
    end
  end
end
{'fraction_non_alphanumeric': 0.11557788944723618, 'fraction_numerical': 0.007816862088218872, 'mean_word_length': 2.1604938271604937, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2388859', 'n_tokens_mistral': 566, 'n_tokens_neox': 539, 'n_words': 134}