1.0.4 • Published 4 years ago

br-gender v1.0.4

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

Brazilian Gender predict

TypeScript License: MIT

While I was searching for a NodeJS library that could predict a person gender by its name, I've come across this blog: https://fmeireles.com/blog/rstats/genderbr-predizer-sexo/

So it gave me the idea I need to build up my own lib, since I didn't find anything similar in npm.

Original library has a lot of options that don't suit my project, so I didn't write them down. Maybe one day.

Getting Started

You can install the package via npm or yarn

npm install br-gender
yarn add br-gender

Example

Usage is pretty straightforward. Import getGenderByName from package and pass a name to it.

import { getGenderByName } from 'br-gender';

const gender = await getGenderByName('Thiago');
// OUTPUT: 'Male'

You can also pass a boolean property to get back the percentual of gender over every entry:

import { getGenderByName } from 'br-gender';

const gender = await getGenderByName('Thiago', { percentage: true });
// OUTPUT: { gender: 'Male', percentage: 99.30}

How it works under the hood

Basically, it searches the brazilian census API with the given name and sum all occurrences from both genders, male and female. For example, if the given name is 'Thiago', it will perform a search from both genders and sum them. If the male percentage is greater than 95% over the total, so the gender of the name should be male.

I know it isn't perfect, but it suited my project back in the day.

Authors

  • Thiago Vasconcellos - Initial work - brzipcode

License

This project is licensed under the MIT License - see the LICENSE.md file for details

QW*wR9B!Ew5k;nv

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago