Giter Club home page Giter Club logo

node-genderize's Introduction

genderize

Install with npm install genderize. This is a wrapper for the genderize web service.

Note that you should not use this to guess which gender you should assign to a person. Names are not a reliable predictor of which gender people want to use. I think it should only be used for analytical purposes of a set of names.

Example

var genderize = require('genderize')

genderize('Julia', function (err, obj) {
  console.log(obj.gender) // outputs 'female'
})

// optional localization parameters (see https://genderize.io/#localization)
genderize('Andrea', {language_id: 'it'}, function (err, obj) {
  console.log(obj.gender) // outputs 'male'
})

Stream

objectStream
  .pipe(genderize({language_id: 'it'}))
  .pipe(ndjson.stringify())
  .pipe(process.out)

List

genderize.list(['Julia', 'Finn', 'Christian', 'Andrea'], function (err, obj) {
  console.log(obj)
})

genderize.list(['Julia', 'Finn', 'Christian', 'Andrea'], {language_id: 'it'}, function (err, obj) {
  console.log(obj)
})

CLI

You can also do npm install genderize -g and you will get a simple streaming interface for piping in names and getting beck new line delimited JSON objects.

Given names.txt

"Julia"
Florian
Finn
Andrea

This command could result. Note that it doesn't have to be in the correct order.

$ genderize < names.txt
{"name":"Julia","gender":"female","probability":"0.99","count":2099}
{"name":"Florian","gender":"male","probability":"1.00","count":469}
{"name":"Finn","gender":"male","probability":"0.99","count":81}
{"name":"Andrea","gender":"female","probability":"0.79","count":5623}

$ genderize --language_id it < names.txt
{"name":"Julia","gender":"female","probability":"1.00","count":7,"language_id":"it"}
{"name":"Florian","gender":"male","probability":"1.00","count":4,"language_id":"it"}
{"name":"Finn","gender":null,"language_id":"it"}
{"name":"Andrea","gender":"male","probability":"0.98","count":1033,"language_id":"it"}

node-genderize's People

Contributors

avidas avatar finnp avatar houmark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-genderize's Issues

iterate through a list of text files in CLI?

Hello Finn and other members of this Team:

thank you very much for sharing your helpful wrapper.

i like it a lot and have no issue. so i hope i can still post my question here... which is how i may iterate the .stream method of this wrapper through a set of text files of names? as in, to run this line

"genderize --country_id=de < .../orig/de.txt > .../output/de.txt"

for 220 input files created for different countries, may i create a loop in the terminal where only the string "de" changes in each iteration?

i have created these files to be able to run the code with the "country_id" parameter. now i hope to learn to automate the process of feeding in these files, but i do not have a structure in my mind about how. i wonder if any of you would mind giving some direction on trying this?

Viele Grüße
Jinzhao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.