# encoding: ascii
# api: powershell
# title: Get-Gender
# description: Guesses the gender of a first name. Uses BabyNameAddicts.com, and works with most common names (not just anglo) ...
# version: 0.1
# type: function
# author: Joel Bennett
# license: CC0
# function: get-gender
# x-poshcode-id: 623
# x-archived: 2012-12-23T23:40:34
# x-published: 2008-10-02T20:19:00
#
# NOTE: this is just for fun. It reports even tiny statistical blips like a few hundred boys named Susan in the 1950’s and girls named Mark in the 1960’s and so on, so you’ll frequently get an inconclusive answer for names you would expect to be solidly one or the other :)
#
function get-gender {
param([string]$name)
if($name.Length -lt 2) { throw "You need at least two letters in the name" }
$name = "$($name[0])".ToUpper() + $name.SubString(1).ToLower()
$page = get-web "http://www.babynameaddicts.com/cgi-bin/search.pl?gender=ALL;searchfield=Names;origins=ALL;searchtype=matching;searchtext=$name"
switch( $page.SelectNodes( "//table//font[ b/descendant::font[contains(text(),'$name')]]" ) | select -expand color ) {
"fucshia" { "Female" }
"#088dd0" { "Male" }
}
}