<commit_before>require 'kabal/languages/language'

class Kabal::English < Kabal::Language
  def convert(number)
    return single number if number >= 0 and number <= 19
    return two_words number if number >= 0 and number <= 99
    return three_words number if number >= 100 and number <= 999
    ten_powers number if number >= 100
  end

  def single(number)
    names[lang]["single"][number]
  end

  def two_words(number)
    return single number if number <= 19
    number_name = names[lang]["two_words"][number / 10]
    number_name += " " + single(number % 10) if (number % 10 != 0)
    number_name
  end

  def three_words(number)
    return two_words number if number <= 99
    number_name = single(number / 100) + " " + names[lang]["ten_powers"][2]
    number_name += " " + two_words(number % 100) if (number % 100 >= 10)
    number_name += " and " + single(number % 100) if (number % 100 < 10)
    number_name
  end

  def ten_powers(number)
    less_thousands number if number_is_thousands? number
    return @number_name if number_is_thousands? number
    create_number_name number
    ten_powers number % (10 ** number_order(number))
  end

  def number_order(number)
    ((number.to_s.length - 1) / 3) * 3
  end

  def count(number)
    number / (10 ** number_order(number))
  end

  def create_number_name(number)
    if @number_name.nil?
      @number_name = count_name(number) + " " + names[lang]["ten_powers"][number_order(number)]
    elsif count(number) != 0
      @number_name += " " + count_name(number) + " " + names[lang]["ten_powers"][number_order(number)]
    end
  end

  def count_name(number)
    three_words count(number)
  end

  def less_thousands(number)
    @number_name += " and" if number < 100
    @number_name += " " + three_words(number % 1000) unless number == 0
  end

  def number_is_thousands?(number)
    number_order(number) < 3
  end
end
<commit_msg>add number out range error for english<commit_after>require 'kabal/languages/language'

class Kabal::English < Kabal::Language
  def convert(number)
    raise NumberOutRangeError.message if number < 0 or number >= 10 ** 12
    return single number if number >= 0 and number <= 19
    return two_words number if number >= 0 and number <= 99
    return three_words number if number >= 100 and number <= 999
    ten_powers number if number >= 100
  end

  def single(number)
    names[lang]["single"][number]
  end

  def two_words(number)
    return single number if number <= 19
    number_name = names[lang]["two_words"][number / 10]
    number_name += " " + single(number % 10) if (number % 10 != 0)
    number_name
  end

  def three_words(number)
    return two_words number if number <= 99
    number_name = single(number / 100) + " " + names[lang]["ten_powers"][2]
    number_name += " " + two_words(number % 100) if (number % 100 >= 10)
    number_name += " and " + single(number % 100) if (number % 100 < 10)
    number_name
  end

  def ten_powers(number)
    less_thousands number if number_is_thousands? number
    return @number_name if number_is_thousands? number
    create_number_name number
    ten_powers number % (10 ** number_order(number))
  end

  def number_order(number)
    ((number.to_s.length - 1) / 3) * 3
  end

  def count(number)
    number / (10 ** number_order(number))
  end

  def create_number_name(number)
    if @number_name.nil?
      @number_name = count_name(number) + " " + names[lang]["ten_powers"][number_order(number)]
    elsif count(number) != 0
      @number_name += " " + count_name(number) + " " + names[lang]["ten_powers"][number_order(number)]
    end
  end

  def count_name(number)
    three_words count(number)
  end

  def less_thousands(number)
    @number_name += " and" if number < 100
    @number_name += " " + three_words(number % 1000) unless number == 0
  end

  def number_is_thousands?(number)
    number_order(number) < 3
  end
end

{'fraction_non_alphanumeric': 0.11456460313382995, 'fraction_numerical': 0.033650141279219115, 'mean_word_length': 3.5069444444444446, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 14, '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': '3492574', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1257, 'n_words': 345}