Genderator: Gender from First Name with Python

Posted 23 Jun 2012 to python and has Comments

I couldn’t find a Python library that would give me a guess for gender based on first name that would handle international names as well, so I started an interface to one written in C. That was taking too long (due to the added complexity around turning the C code into something suitable for a library), so I just wrote a parser for the data file in that project. The code currently doesn’t handle country selection (yet), but it should be suitable enough for most needs. Here’s some basic use:

from genderator.detector import *
d = Detector()

d.getGender('Bob') == MALE # True

d.getGender('Sally') == FEMALE # True

d.getGender('Pauley') == ANDROGYNOUS # True

I18N is fully supported:

d.getGender(u'\301lfr\372n') == FEMALE # True

The code can be found on github.