Skip to content

Commit 5d4dffc

Browse files
committed
Deal with underscores and numbers
1 parent 62d75e7 commit 5d4dffc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

gend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def humps(s):
2323
yield s[a:b]
2424

2525
def parts(s):
26-
for word in re.split(r"\W", s):
26+
for word in re.split(r"[\W_]", s):
2727
for hump in humps(word):
28-
yield hump
28+
yield hump.rstrip('012345679')
2929

3030
TITLES = {
3131
'ms.': 'female',

test_gend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
('Dr. Erik Nelson', 'male'),
1616
('Dr. Mark A. Friedman', 'male'),
1717
('Rev. Johnny Healey', 'male'),
18+
('john_smith', 'male'),
19+
('susie123', 'female'),
1820
])
1921
def test_guess_gender(name, gender):
2022
assert guess_gender(name) == gender

0 commit comments

Comments
 (0)