Skip to content

Commit

Permalink
fix person bug
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Feb 21, 2017
1 parent df1353b commit 61a2324
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"rules": {
"no-cond-assign": 2,
"no-var": 1,
"no-var": 0,
"prefer-const": 0,
"no-extra-parens": 1,
"no-dupe-keys": 2,
Expand Down
14 changes: 7 additions & 7 deletions src/result/subset/people/guessGender.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
'use strict';
const log = require('../../paths').log
// make a statistical assumption about the gender of the person based on their given name
// used for pronoun resolution only.
// not intended for classification, or discrimination of people.
const log = require('../../paths').log;
// make a statistical assumption about the gender of the person based on their given name
// used for pronoun resolution only.
// not intended for classification, or discrimination of people.
const gender = function (firstName) {
if (!firstName) {
return null;
}
//statistical guesses
if (firstName.match(/.(i|ee|[a|e]y|a)$/i)) { //this is almost-always true
log.tell('Female-name suffix')
log.tell('Female-name suffix');
return 'Female';
}
if (firstName.match(/[ou]$/i)) { //if it ends in a 'oh or uh', male
log.tell('Male-name suffix')
log.tell('Male-name suffix');
return 'Male';
}
if (firstName.match(/(nn|ll|tt)/i)) { //if it has double-consonants, female
log.tell('Female-name consonant-doubling')
log.tell('Female-name consonant-doubling');
return 'Female';
}
// name not recognized, or recognized as of indeterminate gender
Expand Down
10 changes: 5 additions & 5 deletions src/result/subset/people/person.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ class Person extends Terms {
this.honorifics = this.match('#Honorific');
this.lastName = this.match('#LastName+');
//assume first-last
if (!this.firstName && this.length === 2) {
if (!this.firstName.found && this.length > 1) {
let m = this.not('(#Acronym|#Honorific)');
this.firstName = m.first();
this.lastName = m.last();
} else {
// this.lastName = this.match('#Person').list[0];
}
return this;
}
Expand All @@ -52,10 +50,12 @@ class Person extends Terms {
return 'Female';
}
//look-for regex clues
return guessGender(this.firstName.out('normal'));
let str = this.firstName.out('normal');
return guessGender(str);
}
pronoun() {
let g = this.guessGender();
let str = this.firstName.out('normal');
let g = this.guessGender(str);
if (g === 'Male') {
return 'he';
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/subset/person/person.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ var tests = {
'Donald Trump': 'Male',
'Rick Warren': 'Male',
'Denzel Washington': 'Male',
'Sardinia F Jones': 'Female',
'Andrew Lloyd Webber': 'Male',
'Michelle Wie': 'Female',
'Serena Williams': 'Female',
Expand All @@ -143,7 +144,6 @@ var tests = {
'Michelle Obama': 'Female',
'Ashton Kutcher': 'Male',
'Cardinal Wolsey': 'Male',
// 'Fulgencia Batista': 'Male',
'Slobodan Milosevic': 'Male',
'Renee Zellweger ': 'Female',
'Whitney Houston ': 'Female',
Expand Down

0 comments on commit 61a2324

Please sign in to comment.