Skip to content

Commit

Permalink
Upgrade to get name from full name function. Updated also version ins…
Browse files Browse the repository at this point in the history
…ide package.json.
  • Loading branch information
davidemiceli committed Aug 5, 2016
1 parent c40dc27 commit d945284
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var female = require('./genders/female');

exports.detect = function(fullName, lang) {
var firstName = getFirstNameFromFullName(fullName);
firstName = firstName.toLowerCase();
resgender = getGender(firstName, lang);
return resgender;
}
Expand All @@ -27,9 +26,7 @@ function getGender(firstName, lang) {
}

function getFirstNameFromFullName(fullName) {
var commaIndex = fullName.indexOf(',');
if (commaIndex >= 0) {
fullName = fullName.split(/,(.+)/)[1].trim();
}
fullName = fullName.toLowerCase();
fullName = fullName.replace(/^\s+|^0-9+|[^a-z-úñäâàáéèëêïîöôùüûœç\- ]+/g, '');
return fullName.split(/\s/)[0];
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gender-detection",
"version": "0.0.2",
"version": "0.0.3",
"description": "Detect the gender of a person using his/her first name.",
"license": "GPL-3.0",
"main": "index.js",
Expand Down

0 comments on commit d945284

Please sign in to comment.