Module: NameableRecord::NameRecognition
- Included in:
- NameRecognizer
- Defined in:
- lib/nameable_record/name_recognition.rb
Instance Method Summary collapse
- #default_disqualifying_words ⇒ Object
- #given_names ⇒ Object
- #human_name?(name, lowest_affirmative_probabilty = 100, disqualifying_words = []) ⇒ Boolean
- #probability_is_human_name(name, disqualifying_words = []) ⇒ Object
- #surnames ⇒ Object
Instance Method Details
#default_disqualifying_words ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/nameable_record/name_recognition.rb', line 44 def %w( corporation corp co llc ltd ) end |
#given_names ⇒ Object
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
25 26 27 |
# File 'lib/nameable_record/name_recognition.rb', line 25 def human_name?( name, lowest_affirmative_probabilty=100, =[] ) probability_is_human_name( name, ) >= 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, =[] ) 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 (( + ) & 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 |
#surnames ⇒ Object
3 4 5 |
# File 'lib/nameable_record/name_recognition.rb', line 3 def surnames @surnames ||= surnames_from_file end |