Project

sexmachine

0.17
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Get gender from first name.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Gender Detector¶ ↑

<img src=“https://secure.travis-ci.org/bmuller/gender_detector.png?branch=master” alt=“Build Status” />

Gender Detector is a Ruby library that will tell you the most likely gender of a person based on first name. It uses the underlying data from the program “gender” by Jorg Michael (described here).

Installation¶ ↑

Add this line to your application’s Gemfile:

gem 'gender_detector'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gender_detector

Usage¶ ↑

Its use is pretty straightforward:

>> require 'gender_detector'
>> d = GenderDetector.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 supported if either UnicodeUtils or ActiveSupport are present. To get I18n support, add either one to your Gemfile:

gem 'unicode_utils' # or gem 'activesupport'

Afterwards, gender detection will work for names with non-ASCII characters as well:

>> 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 GenderDetector. Additionally, you can create a detector that is not case sensitive (default is to be case sensitive):

>> d = GenderDetector.new(:case_sensitive => false)
>> d.get_gender "sally"
 => :female
>> d.get_gender "Sally"
 => :female

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

Licenses¶ ↑

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