Skip to content

Commit 8c55eb9

Browse files
committed
Fix overzealous regex for "Ph. D." (#43)
1 parent b741412 commit 8c55eb9

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

docs/release_log.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Release Log
22
===========
3+
* 1.0.1 - August 30, 2018
4+
- Fix overzealous regex for "Ph. D." (#43)
35
* 1.0.0 - August 30, 2018
46
- Fix support for nicknames in single quotes (#74)
57
- Change prefix handling to support prefixes on first names (#60)

nameparser/config/regexes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
("no_vowels",re.compile(r'^[^aeyiuo]+$', re.I | re.U)),
3131
("period_not_at_end",re.compile(r'.*\..+$', re.I | re.U)),
3232
("emoji",re_emoji),
33-
("phd", re.compile(r'ph\.?\s+d\.?', re.I | re.U)),
33+
("phd", re.compile(r'\s(ph\.?\s+d\.?)', re.I | re.U)),
3434
])
3535
"""
3636
All regular expressions used by the parser are precompiled and stored in the config.

nameparser/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def fix_phd(self):
390390
_re = self.C.regexes.phd
391391
match = _re.search(self._full_name)
392392
if match:
393-
self.suffix_list.append(match.group(0))
393+
self.suffix_list.append(match.group(1))
394394
self._full_name = _re.sub('', self._full_name)
395395

396396
def parse_nicknames(self):

tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,12 @@ def test_phd_with_erroneous_space(self):
16141614
self.m(hn.last, "Smith", hn)
16151615
self.m(hn.suffix, "Ph. D.", hn)
16161616

1617+
def test_phd_conflict(self):
1618+
hn = HumanName("Adolph D")
1619+
self.m(hn.first, "Adolph", hn)
1620+
self.m(hn.last, "D", hn)
1621+
1622+
16171623
# http://en.wikipedia.org/wiki/Ma_(surname)
16181624
def test_potential_suffix_that_is_also_last_name(self):
16191625
hn = HumanName("Jack Ma")

0 commit comments

Comments
 (0)