CodeSOD: Genderize |
If someone suggested that you write a function which, given a persons name, tells you what gender they are, you might caution that this is a hard problem. You might suggest a solution like a Bayesian classifier, which could be trained, or you might say, Maybe we should just let the users tell us.
There are a few things you almost certainly wouldnt suggest. You wouldnt suggest using ColdFusion , because CF is constructed out of sin and unicorn tears. And you certainly wouldnt suggest trying to use regexes to do this job.
Thats because you arent Brents co-worker, who wrote this:
this.genderize(Arguments.firstName)
var regex = "";
regex = "(ua|pher|andy|elijah)$";
if (REFindNoCase(regex, Arguments.name)) {return "male";}
regex = "(a|i|y|ah|ee|et|ette|elle|fer|ine|lyn|ie|anne|een|en|er|yn|ynn|kim|rachel|lind|pam|sue)$";
if (REFindNoCase(regex, Arguments.name)) {return "female";}
return "male";
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |