Skip to content

Commit 95e648e

Browse files
author
Adam Soos
committed
ws-3270: add gender as string
1 parent c685190 commit 95e648e

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

examples/name_similarity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$name_similarity_data1 = "Michael Jackson";
1818
$name_similarity_data2 = "迈克尔·杰克逊";
1919
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
20-
$params = new NameSimilarityParameters(new Name($name_similarity_data1), new Name($name_similarity_data2));
20+
$params = new NameSimilarityParameters(new Name($name_similarity_data1, gender: 'male'), new Name($name_similarity_data2, gender: 'female'));
2121

2222
try {
2323
$result = $api->nameSimilarity($params);

source/rosette/api/Name.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,25 @@ class Name extends RosetteParamsSetBase
4747
*/
4848
public $script;
4949

50+
/**
51+
* Gender of the name. Can be MALE, FEMALE and NONBINARY
52+
*
53+
* @var string
54+
*/
55+
public $gender;
56+
5057
/**
5158
* Constructor.
5259
*
5360
* @param $text
5461
* @param $entityType
5562
* @param $language
5663
* @param $script
64+
* @param $gender
5765
*
5866
* @throws RosetteException
5967
*/
60-
public function __construct($text, $entityType = null, $language = null, $script = null)
68+
public function __construct($text, $entityType = null, $language = null, $script = null, $gender = null)
6169
{
6270
if ($text === null) {
6371
throw new RosetteException(
@@ -69,6 +77,7 @@ public function __construct($text, $entityType = null, $language = null, $script
6977
$this->entityType = $entityType;
7078
$this->language = $language;
7179
$this->script = $script;
80+
$this->gender = $gender;
7281
}
7382

7483
/**

0 commit comments

Comments
 (0)