Skip to main content

This package uses the underlying data from the program “gender” by Jorg Michael (described here). Its use is pretty straightforward:

>>> import sexmachine.detector as gender
>>> d = gender.Detector()
>>> d.get_gender(u"Bob")
u'male'
>>> d.get_gender(u"Sally")
u'female'
>>> d.get_gender(u"Pauley") # should be androgynous
u'andy'

The result will be one of andy (androgynous), male, female, mostly_male, or mostly_female. Any unknown names are considered andies. Moreover, you can set unknown value to whatever you want:

>>> d = gender.Detector(unknown_value=u"ferhat")
>>> d.get_gender(u"Pauley")
u'ferhat'

I18N is fully supported:

>>> d.get_gender(u"Álfrún")
u'female'

Additionally, you can give preference to specific countries:

>>> d.get_gender(u"Jamie")
u'mostly_female'
>>> d.get_gender(u"Jamie", u'great_britain')
u'mostly_male'

Additionally, you can create a detector that is not case sensitive (default is to be case sensitive):

>>> d = sexmachine.detector.Detector(case_sensitive=False)
>>> d.get_gender(u"sally")
u'female'
>>> d.get_gender(u"Sally")
u'female'

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

Licenses

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

Release files for SexMachine 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SexMachine 0.1.1
File Size Uploaded
SexMachine-0.1.1.tar.gz 336.4 kB Details

Release files / SexMachine-0.1.1.tar.gz

Download URL SexMachine-0.1.1.tar.gz
Size 336.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d8059c2c9fe4d8bc3eb3293ae5f4891ca6961274b8cf4869f5c1e5d2901b024e
BLAKE2b-256 checksum
How to use checksums
dd01cc5b32af2b3658079736bd865019aeb8db04f9c5764eac72185c276f3aac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page