diff --git a/.eslintrc b/.eslintrc index cfd661d67..8ba503df1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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, diff --git a/src/result/subset/people/guessGender.js b/src/result/subset/people/guessGender.js index c154bb4a3..b1fce32dd 100644 --- a/src/result/subset/people/guessGender.js +++ b/src/result/subset/people/guessGender.js @@ -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 diff --git a/src/result/subset/people/person.js b/src/result/subset/people/person.js index 35709ebda..76e5de472 100644 --- a/src/result/subset/people/person.js +++ b/src/result/subset/people/person.js @@ -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; } @@ -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'; } diff --git a/test/unit/subset/person/person.test.js b/test/unit/subset/person/person.test.js index fc70428fb..bcb0fb6a2 100644 --- a/test/unit/subset/person/person.test.js +++ b/test/unit/subset/person/person.test.js @@ -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', @@ -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',