<commit_before>module NumbersHelper
  # TODO refactor (seb 2010-10-11)
  def auto_number(value)
    return '-' if value.nil?
    return value unless value.is_a?(Numeric)
    return 'Infinity' if value.to_f.infinite?

    if value > 10**8
      number_with_precision(value.to_f / 10**9, :precision => 2, :delimiter => ",") + " B"
    elsif value > 10**5
      number_with_precision(value.to_f / 10**6, :precision => 2, :delimiter => ",") + " M"
    elsif value > 10**2
      number_with_precision(value.to_f / 10**3, :precision => 2, :delimiter => ",") + " K"
    elsif value >= 1 && value < 100
      number_with_precision value, :precision => 2
    elsif value > 0 && value < 1
      number_with_precision value, :precision => 3
    elsif value === 0
      0
    else
      value
    end
  end
  
  def simple_auto_number(value,unit)
    return '-' if value.nil?
    return value unless value.is_a?(Numeric)
    return 'Infinity' if value.to_f.infinite?
    if unit == '%'
      number_with_precision(value*100,:precision => 1, :separator => ",")
    else
      number_with_precision(value,:precision => 4, :significant => true, :delimiter => ".", :separator => ",")
    end
  end
  
end<commit_msg>numeric values delimiters. closes #217<commit_after>module NumbersHelper
  # TODO refactor (seb 2010-10-11)
  def auto_number(value)
    return '-' if value.nil?
    return value unless value.is_a?(Numeric)
    return 'Infinity' if value.to_f.infinite?

    if value > 10**8
      number_with_precision(value.to_f / 10**9, :precision => 2, :delimiter => ",") + " B"
    elsif value > 10**5
      number_with_precision(value.to_f / 10**6, :precision => 2, :delimiter => ",") + " M"
    elsif value > 10**2
      number_with_precision(value.to_f / 10**3, :precision => 2, :delimiter => ",") + " K"
    elsif value >= 1 && value < 100
      number_with_precision value, :precision => 2
    elsif value > 0 && value < 1
      number_with_precision value, :precision => 3
    elsif value === 0
      0
    else
      value
    end
  end
  
  def simple_auto_number(value,unit)
    return '-' if value.nil?
    return value unless value.is_a?(Numeric)
    return 'Infinity' if value.to_f.infinite?
    if unit == '%'
      number_with_precision(value * 100, :precision => 1)
    else
      number_with_precision(value, :precision => 4, :significant => true,
        :delimiter => ",", :separator => '.')
    end
  end
  
end
{'fraction_non_alphanumeric': 0.14102564102564102, 'fraction_numerical': 0.03763440860215054, 'mean_word_length': 2.920583468395462, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 40, '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': '3490240', 'n_tokens_mistral': 917, 'n_tokens_neox': 808, 'n_words': 205}