New Extension Proposal: Gender
| From: | Anatoliy Belsky | Date: | Sat, 23 Aug 2008 18:00:59 +0000 |
| Subject: | New Extension Proposal: Gender | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-5701@lists.php.net to get a copy of this message | ||
Hi everybody,
I would suggest a new extension named Gender. The extension is supposed to
find out gender by firstname. The working prototype can be downloaded from
there: http://gender.rubay.de/gender-0.5.tar.bz2 .
When downloaded use the
file data/nam_dict.txt.bz2 as base (either unpacked or not). Here just a
little code snippet:
<?php
$gender = new Gender("compress.bzip2:///path/to/nam_dict.txt.bz2");
$name = "Milene";
$country = Gender::FRANCE;
$result = $gender->get($name, $country);
switch($result) {
case Gender::IS_FEMALE:
case Gender::IS_MOSTLY_FEMALE:
printf("The name %s is female in %s\n", $name, $country);
break;
case Gender::IS_MALE:
case Gender::IS_MOSTLY_MALE:
printf("The name %s is male in %s\n", $name, $country);
break;
default:
print "I'm not sure, what gender your name is\n";
break;
}
The entension's code is based on the Joerg Michael's program gender (and he's
data). On my average statistical mashine it attains to find a name in about
0.2 seconds if compressed and in 0.05 seconds if uncompressed. I plan to add
database support in later releases. I hope to increase this characteristics
in future adding database support for data.
Regards
Anatoliy