Get gender from first name in ruby.
Pull request Compare This branch is 24 commits behind bmuller:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
.gitignore
.rvmrc
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
sexmachine.gemspec

README.rdoc

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 = SexMachine::Detector.new
>> d.get_gender("Bob")
:male
>> d.get_gender("Sally")
:female
>> d.get_gender("Pauley") # should be androgynous
:andy

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")
:female

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 = SexMachine::Detector.new(:case_sensitive => 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.

Licenses

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