by bmuller

Get gender from first name in Ruby.

417 Stars 39 Forks Last release: Not found GNU General Public License v3.0 36 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

= Gender Detector {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 'genderdetector' d = d.getgender("Bob") :male d.getgender("Sally") :female d.getgender("Pauley") # should be androgynous :andy

The result will be one of andy (androgynous), male, female, mostlymale, or mostlyfemale. 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.getgender("Jamie") => :female d.getgender("Jamie", :greatbritain) => :mostlymale

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 = => false) d.getgender "sally" => :female d.get_gender "Sally" => :female

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

= Licenses The genderdetector code is distributed under the GPLv3. The data file namdict.txt is released under the GNU Free Documentation License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.