. * * ---------------------------------------------------------------------- * * Class Name: Arabic Gender Guesser * * Filename: ArGender.class.php * * Original Author(s): Khaled Al-Sham'aa * * Purpose: This class attempts to guess the gender of Arabic names * * ---------------------------------------------------------------------- * * Arabic Gender Guesser * * This PHP class attempts to guess the gender of Arabic names. * * Arabic nouns are either masculine or feminine. Usually when referring to a male, * a masculine noun is usually used and when referring to a female, a feminine noun * is used. In most cases the feminine noun is formed by adding a special characters * to the end of the masculine noun. Its not just nouns referring to people that * have gender. Inanimate objects (doors, houses, cars, etc.) is either masculine or * feminine. Whether an inanimate noun is masculine or feminine is mostly * arbitrary. * * Example: * * include('./Arabic.php'); * $obj = new Arabic('ArGender'); * * echo "$name "; * * if ($obj->isFemale($name) == true) { * echo '(Female)'; * }else{ * echo '(Male)'; * } * * * @category I18N * @package Arabic * @author Khaled Al-Shamaa * @copyright 2006-2010 Khaled Al-Shamaa * * @license LGPL * @link http://www.ar-php.org */ // New in PHP V5.3: Namespaces // namespace I18N/Arabic/ArGender; /** * This PHP class attempts to guess the gender of Arabic names * * @category I18N * @package Arabic * @author Khaled Al-Shamaa * @copyright 2006-2010 Khaled Al-Shamaa * * @license LGPL * @link http://www.ar-php.org */ class ArGender { /** * "isFemale" method input charset * @var String */ public $isFemaleInput = 'windows-1256'; /** * Name of the textual "isFemale" method parameters * @var Array */ public $isFemaleVars = array('str'); /** * Loads initialize values */ public function __construct() { } /** * Check if Arabic word is feminine * * @param string $str Arabic word you would like to check if it is * feminine * * @return boolean Return true if input Arabic word is feminine * @author Khaled Al-Shamaa */ public static function isFemale($str) { $female = false; $words = explode(' ', $str); $str = $words[0]; $last = strlen($str) - 1; if ($str[$last] == 'É' || $str[$last] == 'å' || $str[$last] == 'ì' || $str[$last] == 'Ç' || ($str[$last] == 'Á' && $str[$last-1] == 'Ç')) { $female = true; } return $female; } }