gender-detection-from-name
Advanced tools
Comparing version 1.7.4 to 1.8.0
@@ -8,3 +8,3 @@ { | ||
}, | ||
"extends": "google", | ||
"extends": ["eslint:recommended", "google"], | ||
"parserOptions": { | ||
@@ -11,0 +11,0 @@ "ecmaVersion": 12 |
declare module "gender-detection-from-name" { | ||
export function getGender(name: string, lang?: 'en' | 'it'): string; | ||
export function getGender(name: string, lang?: 'en' | 'it' | 'es'| 'fr'): string; | ||
} |
const enMap = require('./names/en'); | ||
const itMap = require('./names/it'); | ||
const esMap = require('./names/es'); | ||
const frMap = require('./names/fr'); | ||
@@ -20,3 +22,5 @@ /** | ||
it: itMap, | ||
all: new Map([...itMap, ...enMap]), | ||
es: esMap, | ||
fr: frMap, | ||
all: new Map([...itMap, ...enMap, ...esMap, ...frMap]), | ||
}; | ||
@@ -23,0 +27,0 @@ // Use the Map of input language, or use all |
{ | ||
"name": "gender-detection-from-name", | ||
"version": "1.7.4", | ||
"version": "1.8.0", | ||
"description": "Gender detection from first name", | ||
@@ -30,7 +30,7 @@ "main": "index.js", | ||
"devDependencies": { | ||
"eslint": "^8.10.0", | ||
"eslint": "^8.47.0", | ||
"eslint-config-google": "^0.14.0", | ||
"mocha": "^10.0.0", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0" | ||
} | ||
} |
@@ -17,8 +17,15 @@ # Gender detection from name | ||
const genderIT = getGender('Andrea', 'it'); | ||
const genderES = getGender('Andrea', 'es'); | ||
const genderFR = getGender('Andrea', 'fr'); | ||
const gender = getGender('Jennifer'); | ||
console.log(genderEN); // female | ||
console.log(genderIT); // male | ||
console.log(genderES); // male | ||
console.log(genderFR); // male | ||
console.log(gender); // female | ||
``` | ||
### Supported languages | ||
`en`, `it`, `es`, `fr` | ||
### Run tests | ||
@@ -30,3 +37,6 @@ ```npm test``` | ||
### Contribute | ||
Feel free to contribute to this project to add more names in different languages. | ||
### Author | ||
- [Davide Violante](https://github.com/DavideViolante/) |
@@ -29,2 +29,26 @@ const assert = require('assert'); | ||
}); | ||
it('should return male for some spanish male names', () => { | ||
const names = ['Manolo', 'Fernando', 'Markel', 'Miguel']; | ||
for (const name of names) { | ||
assert.strictEqual(getGender(name, 'es'), 'male'); | ||
} | ||
}); | ||
it('should return male for some spanish female names', () => { | ||
const names = ['Maria', 'Luisa', 'Juana', 'Aintzane', 'Gemma']; | ||
for (const name of names) { | ||
assert.strictEqual(getGender(name, 'es'), 'female'); | ||
} | ||
}); | ||
it('should return male for some french male names', () => { | ||
const names = ['David', 'Presley', 'Giacomo', 'Giorgio', 'Anastase']; | ||
for (const name of names) { | ||
assert.strictEqual(getGender(name, 'fr'), 'male'); | ||
} | ||
}); | ||
it('should return female for some french female names', () => { | ||
const names = ['Pome', 'Princesse', 'Sahana', 'Marta', 'Elida']; | ||
for (const name of names) { | ||
assert.strictEqual(getGender(name, 'fr'), 'female'); | ||
} | ||
}); | ||
it('should return male for some names with wrong language', () => { | ||
@@ -31,0 +55,0 @@ const names = ['Dave', 'John', 'Giacomo', 'George', 'Luca']; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2054346
15
85375
41