Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including wikidata-names with all npm packages installed. Try it out:

var wikidataNames = require("wikidata-names")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

wikidata-names v1.0.0

name datasets from wikidata

wikidata-names

First names and family names

Data is queried from Wikidata.

Credits go to wikidata-person-names for the SPARKQL queries.

Usage

plain names as array...

const {
  female,
  family,
  male,
  unisex
} = require('wikidata-names')

console.log(female)
// => [" 法蕾莉-安妮","A'Lee","A'isha","A-ra","A-rum",...]
console.log(male)
// => [" 於爾基","A-Jay","Aad","Aadolf","Aadu",...]

names with language info

const {
  female,
  family,
  male,
  unisex,
  byLanguage
} = require('wikidata-names/lang')

console.log(female)
// => {" 法蕾莉-安妮":["zh-hant","zh-tw"],"A'Lee":["ast","en","sq"],... }
console.log(male)
// => {" 於爾基":["zh-hant","zh-tw"],"A-Jay":["en","sq"],"Aad":["af","an",...,"tr"],...}

wikidata-names/lang comes with a helper function byLanguage to group, filter and join names by language.

const {
  female,
  byLanguage
} = require('wikidata-names/lang')

// group names by language
const names = byLanguage(female)
//> Object.keys(names) === [ 'aa', 'ab', 'ace', ..., 'zh-sg', 'zh-tw' ]
//> names.aa = [ 'Aafje', 'Aagot', 'Aaliyah', 'Aamina', 'Aanchal', 'Aasa', ... ]

// group and filter for 'en' and 'fr'
const names = byLanguage(female, { filter: ['en', 'fr'] })
//> names.en = [ "A'Lee", "A'isha", 'A-ra', ... ]
//> names.fr = [ "A'isha", 'Aadya', 'Aaf', ... ]

// filter by regex
const names = byLanguage(female, { filter: /^en/ })
//> Object.keys(names) === [ 'en', 'en-ca', 'en-gb' ]

// filter and join all names; returns an array, not object!
const names = byLanguage(female, { filter: /^en/, join: true })
//> names = [ "A'Lee", "A'isha", 'A-ra', 'Aabha', ... ]

Note

The family names dataset is incomplete compared to all data available on wikidata. The long running query may have been prematurely aborted.

License

Code is licensed under Unlicense.

Data is from Wikidata and licensed under CC0.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free