コード例 #1
0
 def test_capitalize_roman_numeral_suffixes(self):
     self.assertEqual('Ken Cuccinelli, II', str(PoliticianNameCleaver('KEN CUCCINELLI II').parse()))
     self.assertEqual('Ken Cuccinelli, II', str(PoliticianNameCleaver('CUCCINELLI II, KEN').parse()))
     self.assertEqual('Ken T. Cuccinelli, II', str(PoliticianNameCleaver('CUCCINELLI II, KEN T').parse()))
     self.assertEqual('Ken T. Cuccinelli, II', str(PoliticianNameCleaver('CUCCINELLI, KEN T II').parse()))
     self.assertEqual('Ken Cuccinelli, IV', str(PoliticianNameCleaver('CUCCINELLI IV, KEN').parse()))
     self.assertEqual('Ken Cuccinelli, IX', str(PoliticianNameCleaver('CUCCINELLI IX, KEN').parse()))
コード例 #2
0
 def test_case_converts_in_non_mixed_case_names_only(self):
     self.assertEqual('Antonio dAlesio', str(PoliticianNameCleaver('Antonio dAlesio').parse()))
コード例 #3
0
 def test_handles_empty_names(self):
     self.assertEqual('', str(PoliticianNameCleaver('').parse()))
コード例 #4
0
 def test_running_mates_with_metadata(self):
     self.assertEqual('Ted Strickland & Lee Fischer (D-OH)', str(PoliticianNameCleaver('STRICKLAND, TED & FISCHER, LEE').parse().plus_metadata('D', 'OH')))
コード例 #5
0
 def test_edgar_de_lisle_ross(self):
     name = PoliticianNameCleaver('Edgar de L\'Isle Ross (R)').parse()
     self.assertEqual('Edgar', name.first)
     self.assertEqual('de L\'Isle', name.middle)
     self.assertEqual('Ross', name.last)
     self.assertEqual(None, name.suffix)
コード例 #6
0
 def test_doesnt_misinterpret_roman_numeral_characters_in_last_name_as_suffix(self):
     self.assertEqual('Vickers', PoliticianNameCleaver('Audrey C Vickers').parse().last)
コード例 #7
0
 def test_name_with_two_part_last_name(self):
     self.assertEqual('La Mere', PoliticianNameCleaver('Albert J La Mere').parse().last)
     self.assertEqual('Di Souza', PoliticianNameCleaver('Dinesh Di Souza').parse().last)
コード例 #8
0
    def test_we_dont_need_no_steeenking_nicknames(self):
        self.assertEqual('Robert M. McDonnell', str(PoliticianNameCleaver('McDonnell, Robert M (Bob)').parse()))
        self.assertEqual('John J. Duncan, Jr.', str(PoliticianNameCleaver('John J (Jimmy) Duncan Jr (R)').parse()))
        self.assertEqual('Christopher Bond', str(PoliticianNameCleaver('Christopher "Kit" Bond').parse()))

        self.assertEqual('"Kit"', IndividualNameCleaver('Christopher "Kit" Bond').parse().nick)
コード例 #9
0
 def test_politician(self):
     self.assertEqual(u'Tobias F\u00fcnke'.encode('utf-8'),
             str(PoliticianNameCleaver(u'F\u00fcnke, Tobias').parse()))
コード例 #10
0
 def test_last_first(self):
     self.assertEqual('Albert Gore', str(PoliticianNameCleaver('Gore, Albert').parse()))
コード例 #11
0
 def test_not_everything_is_a_scot(self):
     self.assertEqual('Adam Mack', str(PoliticianNameCleaver('ADAM MACK').parse()))
     self.assertEqual('Don Womackey', str(PoliticianNameCleaver('DON WOMACKEY').parse()))
コード例 #12
0
 def test_first_last_mixed_case_with_party(self):
     self.assertEqual('Nancy Pelosi', str(PoliticianNameCleaver('Nancy Pelosi (D)').parse()))
コード例 #13
0
 def test_last_first_mixed_case_scot_with_party(self):
     self.assertEqual('Emory MacDonald', str(PoliticianNameCleaver('MacDonald, Emory (R)').parse()))
コード例 #14
0
 def test_upper_case_scot_with_party(self):
     self.assertEqual('Emory MacDonald', str(PoliticianNameCleaver('MACDONALD, EMORY (R)').parse()))
コード例 #15
0
 def test_alternate_punctuation(self):
     self.assertEqual('Charles W. Boustany, Jr.', str(PoliticianNameCleaver('Charles W. Boustany Jr.').parse()))
コード例 #16
0
 def test_standardize_running_mate_names(self):
     self.assertEqual('John Kasich & Mary Taylor', str(PoliticianNameCleaver('Kasich, John & Taylor, Mary').parse()))
コード例 #17
0
 def test_standardize_running_mate_names_with_slash(self):
     self.assertEqual('Mitt Romney & Paul D. Ryan', str(PoliticianNameCleaver('ROMNEY, MITT / RYAN, PAUL D.').parse()))
コード例 #18
0
 def test_politician_plus_metadata(self):
     self.assertEqual(u'Tobias F\u00fcnke (D-CA)'.encode('utf-8'),
             str(PoliticianNameCleaver(u'F\u00fcnke, Tobias').parse().plus_metadata('D', 'CA')))
コード例 #19
0
 def test_politician_running_mates(self):
     self.assertEqual(u'Tobias F\u00fcnke & Lindsay F\u00fcnke'.encode('utf-8'),
             str(PoliticianNameCleaver(u'F\u00fcnke, Tobias & F\u00fcnke, Lindsay').parse()))
コード例 #20
0
 def test_pile_it_on(self):
     self.assertEqual('Milton Elmer McCullough, Jr.', str(PoliticianNameCleaver('Milton Elmer "Mac" McCullough, Jr (3)').parse()))
コード例 #21
0
 def test_deals_with_last_names_that_look_like_two_part_but_are_not(self):
     name = PoliticianNameCleaver('Quoc Van (D)').parse()
     self.assertEqual('Quoc', name.first)
     self.assertEqual('Van', name.last)
コード例 #22
0
 def test_running_mates_with_metadata(self):
     self.assertEqual(u'Ted Strickland & Le\u00e9 Fischer (D-OH)'.encode('utf-8'),
             str(PoliticianNameCleaver(u'STRICKLAND, TED & FISCHER, LE\u00c9').parse().plus_metadata('D', 'OH')))
コード例 #23
0
 def test_multiple_middle_names(self):
     self.assertEqual('Swift Eagle', PoliticianNameCleaver('Alexander Swift Eagle Justice').parse().middle)
コード例 #24
0
 def test_unparseable_politician_name(self):
     with self.assertRaises(UnparseableNameException):
         PoliticianNameCleaver("mr & mrs").parse()
コード例 #25
0
 def test_with_metadata(self):
     self.assertEqual('Charles Schumer (D-NY)', str(PoliticianNameCleaver('Charles Schumer').parse().plus_metadata('D', 'NY')))
     self.assertEqual('Barack Obama (D)', str(PoliticianNameCleaver('Barack Obama').parse().plus_metadata('D', '')))
     self.assertEqual('Charles Schumer (NY)', str(PoliticianNameCleaver('Charles Schumer').parse().plus_metadata('', 'NY')))
     self.assertEqual('Jerry Leon Carroll', str(PoliticianNameCleaver('Jerry Leon Carroll').parse().plus_metadata('', '')))  # only this one guy is missing both at the moment
コード例 #26
0
 def test_pile_it_on_two(self):
     self.assertEqual('William Steve Southerland, II', str(PoliticianNameCleaver('William Steve Southerland  II (R)').parse()))
コード例 #27
0
 def test_names_with_weird_parenthetical_stuff(self):
     self.assertEqual('Lynn Swann', str(PoliticianNameCleaver('SWANN, LYNN (COMMITTEE 1)').parse()))
コード例 #28
0
 def test_pile_it_on_three(self):
     self.assertEqual('Edward Thomas O\'Donnell, Jr.', str(PoliticianNameCleaver('Edward Thomas O\'Donnell, Jr (D)').parse()))
コード例 #29
0
 def test_capitalize_irish_names(self):
     self.assertEqual('Sean O\'Leary', str(PoliticianNameCleaver('SEAN O\'LEARY').parse()))
コード例 #30
0
 def test_alternate_running_mates_format(self):
     self.assertEqual('Obama/Biden 2012', str(PoliticianNameCleaver('2012, Obama/Biden').parse()))