<commit_before>class PhoneNumber

  attr_reader :number, :area_code
  INVALID = '0' * 10

  def initialize(input)
    if contains_letters?(input)
      @number = INVALID
    else
      @number = clean_up(input)
    end
    @area_code = number[0..2]
  end

  def to_s
    '(' + number[0..2] + ') ' + number[3..5] + '-' + number[6..9]
  end

  private

  def clean_up(input)
    regex = /\D/
    stripped = input.gsub(regex, '')
    if stripped.length == 11 && stripped[0] == '1'
      stripped[1..-1]
    elsif stripped.length == 10
      stripped
    else
      INVALID
    end
  end

  def contains_letters?(input)
    return true if input.match(/[a-zA-Z]/)
    false
  end
    
end<commit_msg>remove trailing whitespace and clean up contains_letters<commit_after>class PhoneNumber

  attr_reader :number, :area_code
  INVALID = '0' * 10

  def initialize(input)
    if contains_letters?(input)
      @number = INVALID
    else
      @number = clean_up(input)
    end
    @area_code = number[0..2]
  end

  def to_s
    '(' + number[0..2] + ') ' + number[3..5] + '-' + number[6..9]
  end

  private

  def clean_up(input)
    regex = /\D/
    stripped = input.gsub(regex, '')
    if stripped.length == 11 && stripped[0] == '1'
      stripped[1..-1]
    elsif stripped.length == 10
      stripped
    else
      INVALID
    end
  end

  def contains_letters?(input)
    input.match(/[a-zA-Z]/)
  end

end
{'fraction_non_alphanumeric': 0.13817663817663817, 'fraction_numerical': 0.027065527065527065, 'mean_word_length': 2.3058823529411763, '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': '4871651', 'n_tokens_mistral': 530, 'n_tokens_neox': 502, 'n_words': 115}