File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed
src/org/nameapi/client/services/genderizer
tests/functional/org/nameapi/client/services/genderizer/persongenderizer Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function __construct(Context $context) {
2424 /**
2525 * @return persongenderizer\PersonGenderizerService
2626 */
27- public function personGenderizerService () {
27+ public function personGenderizer () {
2828 if ($ this ->personGenderizerService ==null ) {
2929 $ this ->personGenderizerService = new persongenderizer \PersonGenderizerService ($ this ->context );
3030 }
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class AssessResponse {
2020 public function getReturn () {
2121 return new PersonGenderResult (
2222 new ComputedPersonGender ($ this ->return ->gender ),
23- $ this ->return ->maleProportion ,
23+ isSet ( $ this ->return ->maleProportion ) ? $ this -> return -> maleProportion : null ,
2424 $ this ->return ->confidence
2525 );
2626 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace org \nameapi \client \services \genderizer \persongenderizer ;
4+
5+ require_once (__DIR__ .'/../../BaseServiceTest.php ' );
6+
7+ use org \nameapi \client \services \BaseServiceTest ;
8+ use org \nameapi \ontology \input \entities \person \NaturalInputPerson ;
9+ use org \nameapi \ontology \input \entities \person \name \InputPersonName ;
10+
11+ class PersonGenderizerServiceTest extends BaseServiceTest {
12+
13+ public function testMale () {
14+ $ personGenderizer = $ this ->makeServiceFactory ()->genderizerServices ()->personGenderizer ();
15+ $ inputPerson = NaturalInputPerson::builder ()
16+ ->name (InputPersonName::westernBuilder ()
17+ ->fullname ( "John F. Kennedy " )
18+ ->build ())
19+ ->build ();
20+ $ personGenderResult = $ personGenderizer ->assess ($ inputPerson );
21+ $ this ->assertEquals ('MALE ' , $ personGenderResult ->getGender ()->toString ());
22+ }
23+
24+ public function testFemale () {
25+ $ personGenderizer = $ this ->makeServiceFactory ()->genderizerServices ()->personGenderizer ();
26+ $ inputPerson = NaturalInputPerson::builder ()
27+ ->name (InputPersonName::westernBuilder ()
28+ ->fullname ( "Angela Merkel " )
29+ ->build ())
30+ ->build ();
31+ $ personGenderResult = $ personGenderizer ->assess ($ inputPerson );
32+ $ this ->assertEquals ('FEMALE ' , $ personGenderResult ->getGender ()->toString ());
33+ }
34+
35+ }
You can’t perform that action at this time.
0 commit comments