Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: e38ac1a4bc
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (28 sloc) 1.32 KB

Sex Machine

This gem uses the underlying data from the program “gender” by Jorg Michael (described here). It's use is pretty straightforward:

>> require 'sexmachine'
>> d =
>> d.get_gender("Bob")
>> d.get_gender("Sally")
>> d.get_gender("Pauley") # should be androgynous

The result will be one of andy (androgynous), male, female, mostly_male, or mostly_female. Any unknown names are considered andies.

I18N is fully supported:

>> d.get_gender("Álfrún")

Additionally, you can give preference to specific countries:

>> d.get_gender("Jamie")
 => :female
>> d.get_gender("Jamie", :great_britain)
 => :mostly_male

If you have an alterative data file, you can pass that in as an optional filename argument to the Detector. Additionally, you can create a detector that is not case sensitive (default is to be case sensitive):

>> d = => false)
>> d.get_gender "sally"
 => :female
>> d.get_gender "Sally"
 => :female

Try to avoid creating many Detectors, as each creation means reading in the data file.


The genderator code is distributed under the GPLv3. The data file nam_dict.txt is released under the GNU Free Documentation License.

Jump to Line
Something went wrong with that request. Please try again.