Module: NameableRecord::NameRecognition

Included in:
NameRecognizer
Defined in:
lib/nameable_record/name_recognition.rb

Instance Method Summary collapse

Instance Method Details

#default_disqualifying_wordsObject



44
45
46
47
48
49
50
51
52
# File 'lib/nameable_record/name_recognition.rb', line 44

def default_disqualifying_words
  %w(
    corporation
    corp
    co
    llc
    ltd
  )
end

#given_namesObject



7
8
9
# File 'lib/nameable_record/name_recognition.rb', line 7

def given_names
  @given_names ||= given_names_from_file
end

#human_name?(name, lowest_affirmative_probabilty = 100, disqualifying_words = []) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/nameable_record/name_recognition.rb', line 25

def human_name?( name, lowest_affirmative_probabilty=100, disqualifying_words=[]  )
  probability_is_human_name( name, disqualifying_words ) >= lowest_affirmative_probabilty
end

#probability_is_human_name(name, disqualifying_words = []) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nameable_record/name_recognition.rb', line 29

def probability_is_human_name( name, disqualifying_words=[] )
  if name.match( /^[a-zA-Z]*\s*[a-zA-Z]{2}$/ )
    return probability_from_last_and_intials( name, :last_name_first => true )
  elsif name.match( /^[a-zA-Z]{2}\s*[a-zA-Z]*$/ )
    return probability_from_last_and_intials( name, :last_name_first => false )
  end

  name_parts = split_and_clean_name( name )

  return 0 if ((default_disqualifying_words + disqualifying_words) & name_parts).size > 0

  score = (100 - ((name_parts.size - (name_parts & all_name_words_downcase).size) * points_per_additional_word))
  score < 0 ? 0 : score
end

#surnamesObject



3
4
5
# File 'lib/nameable_record/name_recognition.rb', line 3

def surnames
  @surnames ||= surnames_from_file
end