<commit_before>class NameMatcher

  SUFFIXES = %w(i ii iii iv v vi vii viii x jr sr)

  def initialize(first_name, last_name)

    @first_name = first_name.strip.downcase
    @last_name = last_name.strip.downcase
    @full_name = @first_name + " " + @last_name
  end


  def match(test_first_name, test_last_name)
      test_first_name = test_first_name.downcase
      test_last_name = test_last_name.downcase

      test_full_name = test_first_name.strip + " " + test_last_name.strip

      test_full_name = test_full_name.downcase

      return true if @full_name.eql?(test_full_name) # both names exactly same

      return true if @full_name.gsub(/[-.]/,' ').gsub('  ', ' ').eql?(test_full_name.gsub(/[-.]/,' ').gsub('  ', ' ')) # both names same after removing '-'

      return false unless @first_name.eql?(test_first_name)

      if(@last_name.length > test_last_name.length)
        diff = @last_name.split('') - test_last_name.split('') # convert to array and subtract to get difference
      else
        diff = test_last_name.split('') - @last_name.split('') # convert to array and subtract to get difference
      end

      diff = diff.join('').strip.gsub('.','') # remove any '.'

      diff = diff.split(' ') #array will include one or more suffixes e.g. iii jr

      SUFFIXES.length > (SUFFIXES - diff).length
  end
end<commit_msg>added full name match<commit_after>class NameMatcher

  SUFFIXES = %w(i ii iii iv v vi vii jr sr)

  def initialize(first_name, last_name)

    @first_name = first_name.strip.downcase
    @last_name = last_name.strip.downcase
    @full_name = @first_name + @last_name
    @normalized_full_name = normalize(@full_name)
  end

  def match(test_first_name, test_last_name)

    test_full_name = (test_first_name + test_last_name).downcase
    normalized_test_full_name = normalize(test_full_name)

    return true if @normalized_full_name.eql? normalized_test_full_name # names are same

    diff = nil


    # test if difference between two name is a SUFFIX
    if(@normalized_full_name.length > normalized_test_full_name.length)
      #diff = (@normalized_full_name.split('') - normalized_test_full_name.split('')).join('')
      #puts "1 #{@normalized_full_name} #{normalized_test_full_name}"
      diff = @normalized_full_name.gsub(normalized_test_full_name,'')
    else
      #diff = (normalized_test_full_name.split('') - @normalized_full_name.split('')).join('')
      #puts "2 #{@normalized_full_name} #{normalized_test_full_name}"
      diff = normalized_test_full_name.gsub(@normalized_full_name, '')
    end

    #puts "#{diff.to_s} diff is blank? #{diff.blank?}"

    SUFFIXES.include?(diff) || diff.blank?
  end

  private

  def normalize(name)
    name.gsub(/[^a-z]/i, '')
  end
end
{'fraction_non_alphanumeric': 0.12212905577834487, 'fraction_numerical': 0.0007291286912139992, 'mean_word_length': 3.68259385665529, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2442168', 'n_tokens_mistral': 973, 'n_tokens_neox': 941, 'n_words': 199}