Module: Fullname::Parser

Extended by:
Parser
Included in:
Parser
Defined in:
lib/fullname/parser.rb,
lib/fullname/parser/version.rb

Defined Under Namespace

Classes: Error, Identifier

Constant Summary collapse

GENERATION_LIST =

When “II” or “III” or even “IV” appear in the Middle Name/Suffix slot, it can safely be assumed that they are Suffixes. (John Smith has a son named John Smith II, who has a son named John Smith III, etc.) However, nobody (except a king) puts “I” after their name to indicate that they are the “first.” If anything, they put “Sr.” Therefore, a letter “I” appearing in the Middle Name/Suffix slot can be assumed to be their Middle Initial. So here ‘i’ will be removed from the GENERATION_LIST

Also almost nobody will reach to ‘v’(except a king), so all suffixes later than ‘v’ we won’t use.

[
  'ii', 'iii', 'iv', 'v', 'vi'
  # 'vii', 'viii', 'ix', 'x', 'xi', 'xii', 'xiii', 'xiv', 'xv', 'xvi', 'xvii', 'xviii', 'xix', 'xx',
]
GLOBAL_SUFFIX_LIST =
GENERATION_LIST + [
  'jr', 'jr.',
  'sr', 'sr.',
]
SUFFIX_LIST =
[
  'b.a.',
  'capt.', 'col.', 'cfa', 'c.f.a', 'c.f.a.', 'cpa', 'c.p.a', 'c.p.a.',
  'edd', 'ed.d',
  'mph',
  'pc', 'p.c.', 'psyd', 'psyd.', 'psy.d', 'phd', 'phd.', 'ph.d', 'ph.d.',
  'r.s.m.',
  'usn',
]
IGNORABLE_SUFFIXES =
[
  'do', 'd.o.', 'd.o', 'dds', 'd.d.s.', 'dr', 'dr.',
  'esq', 'esq.',
  # Doctor suffixes
  # http://books.google.com/books?id=J6kLNKw5baYC&pg=PA336&lpg=PA336&dq=faafp+faan+facaai&source=bl&ots=BJ4AvvSF9e&sig=Xj950-otl-X-tX_2I5DvGY4_uuE&hl=en&sa=X&ei=_9DHUdT2MOn6iwKR1oGAAw&ved=0CCoQ6AEwAA#v=onepage&q=faafp%20faan%20facaai&f=false
  'faafp', 'faan', 'facaai', 'facc', 'facd', 'facg', 'faap', 'facog', 'facp', 'facpm', 'facs', 'facsm', 'fama', 'faota', 'fapa', 'fapha', 'fcap', 'fccp', 'fcps', 'fds', 'faao', 'fics',
  'md', 'm.d.', 'm.d',
  'mr.', 'ms.', 'mrs.',
  'od', 'o.d.',
  'pa', 'p.a.', 'ps', 'p.s.',
  'jd', 'jd.', 'j.d.',
  'retd', 'ret.', 'retd.',
  'usmc',
]
SUFFIX_CAN_BE_LASTNAME =
[
  'do',
]
PREFIX_LIST =
[ 
  'asst.',
  'assoc.', 'associate',  # va law
  'asst. dean', 'associate dean', 'interim dean',  # va law
  'attorney', 'atty.',
  'bg', 'bg.', 'brig', 'brig.', 'gen',
  'colonel', 'cardinal', 'capt', 'capt.', 'captain', 'cdr', 'col' , 'col.', 'congressman', 'cpt', 'cpt.', 'comm.',
  'dean.', 'dentist', 'dir.', 'doctor', 'dr', 'dr.',
  'exec.',
  'general', 'gen', 'gen.',
  'honorable', 'hon', 'hon.', 'honret.',
  'interim', 'instructor',  # va law
  'judge', 'justice', 'chiefjustice',
  'lawyer', 'lieutenant', 'lcdr', 'lt', 'lt.', 'ltc', 'ltc.', 'ltcol.', 'ltcol', 'ltjg', 
  'm/g', 'mr', 'mr.', 'mr..', 'ms', 'ms.', 'mrs', 'mrs.', 'maj', 'maj.', 'major', 'miss', 'miss.',
  'president', 'prof', 'prof.', 'professor',
  'rabbi',
  'reverend', 'rev', 'rev.',
  'sheriff',
  'sis.', 'sr', 'sr.'
]
IGNORABLE_PREFIXS =
[
  'the',
]
LAST_NAME_EXTENSIONS =

These will be considered part of the last name

[    
  'bar', 'ben',
  'da', 'dal', 'dan', 'de', 'del', 'den', 'der', 'des', 'dela', 'della', 'di', 'do', 'du',
  'el',
  'la', 'le', 'lo',
  'mac', 'mc',
  'san',
  'st', 'st.', 'sta', 'sta.',
  'van','von', 'ver', 'vanden', 'vander'
]
CONVERSION =
{
  '1st' => 'I', 
  '2nd' => 'II', 
  '3rd' => 'III', 
  '4th' => 'IV',
  '5th' => 'V',
  '6th' => 'VI',
  '7th' => 'VII',
  '8th' => 'VIII',
  '9th' => 'IX',
}
VERSION =
'1.1.3'

Instance Method Summary collapse

Instance Method Details

#parse_fullname(name) ⇒ Object



266
267
268
269
270
271
272
273
274
275
# File 'lib/fullname/parser.rb', line 266

def parse_fullname(name)
  i = Identifier.new(name)
  return {
    prefix: i.prefix,
    first: i.firstname,
    middle: i.middlename,
    last: i.lastname,
    suffix: i.suffix
  }
end