views:

195

answers:

5

Hi guys, I recently confronted with a weird yet interesting question. The questions is as follows: Need to write a program which can give the gender as output based on the name. Example: INPUT --> John Michael Britney OUTPUT--> male male female

So this is the output I expect. I tried a lot to solve, but I really was not able to crack it. I will be really thankful to this site for giving me an opportunity to share this question.

Actually this is asked in a programming contest as a flyer problem, so I thought this can be programmed.

+1  A: 

I have done this before - it is easy and works well 90% of the time when applied to the correct scenario.

You need to obtain a database of names and the usual gender from somewhere. It is then trivial to search the database.

Some names (for example Andy) are commonly associated with either gender. So you will need at least three gender values - male/female/unknown.

cbp
But I don't think it is feasible to cover all the names in the world. Is there no other way, logically.
Ramesh
Of course not, no
cbp
+5  A: 

You can't do it algorithmically: you need a database to do it statistically. This SO question points to many such available resources. Do realize you'll have many, MANY misguesses -- either the Korean Kim's (males) or the Northern European ones (females) may get pretty peeved at that kind of thing, for example;-).

Alex Martelli
+1 - trying to guess someone's gender from their name is a bad idea because it is liable to cause offence if you get it wrong.
Stephen C
Saturday Night Live used to have a running sketch about people trying to guess the gender of a person named "Pat". There are many other given names that can be applied to either gender, such as "Leslie" or "Jackie".
Bob Murphy
Yep, and even for names that are statistically well connected with gender, there will always be enough exceptions to cause trouble -- Doonesbury's daughter's named "Alex", I have a dear (male) friend his (Irish) mother named "Shannon", "Andrea" is mostly female in some cultures (e.g., Germany), but strongly male in Italy -- etc, etc.
Alex Martelli
Don't forget northern european males. *ahem*
Pekka
+1  A: 

Check out WolframAlpha.com. They have a webservice API, but it's a bit pricy...

http://products.wolframalpha.com/api/pricing.html

Joe Pruitt
+2  A: 

Don't give up.

I would take a statistical approach... you need to get your hands on a massive names database that actually has gender info... then teach your program to learn from that dataset.

The thing is you need a third variable for correlation. Something like country of origin, ethnicity, etc will narrow your odds even further. You really need that 3rd "clue"...

helpless
A: 

What about Human Computer Interaction as the 3rd clue.

You could have a click map such as http://css-tricks.com/tracking-clicks-building-a-clickmap-with-php-and-jquery/

Based on where the user clicks you could determine a reasonable statistic of male vs. female. This would be used when unknown is in the database

Heres a Wikipedia on "Gender_HCI":

"Larger displays helped reduce the gender gap in navigating virtual environments. With smaller displays, males’ performance was better than females’. With larger displays, females’ performance improved and males’ performance was not negatively affected."

So have a small box and time the amount of time required to click it. ...?

aneuway