I guess male
<cfparam name="attributes.text" default="Tracy Smith is our finest pole-vaulter. He has set many team records, and his personal best is 19' 8"". Tracy's other hobbies are race cars and reading about the migration of polar bears, but his real passion is fly fishing. His eight year old daughter also loves fishing, and she always catches the big ones!" />
<cfscript>
function getPoints(text, words) {
var i = "";
words = listToArray(words);
for (i = 1; i LTE arrayLen(words); i = i + 1) {
text = REReplace(text, "(^|[^[:alpha:]])#words[i]#([^[:alpha:]]|$)", "\1#chr(7)#\2", "all");
}
return listLen(text, chr(7));
}
function guessSex(text) {
text = " " & lCase(text) & " ";
mPoints = getPoints(text, "mr.,he,him,his");
fPoints = getPoints(text, "mrs.,ms.,miss,she,her,hers");
if (mPoints == fPoints) {
return "unknown";
} else if (mPoints GT fPoints) {
return "male";
} else {
return "female";
}
}
</cfscript>
<cfoutput>
<form method="post">
<textarea name="text" style="width:500px;height:100px">#attributes.text#</textarea><br />
<input type="submit" />
</form>
I guess <strong>#guessSex(attributes.text)#</strong>
<hr />
<pre>#htmlEditFormat(fileRead(getCurrentTemplatePath()))#</pre>
<!--- a Groovy version
def guessSex = { text ->
def counts = text.toLowerCase().tokenize().groupBy{ it }
def getPoints = { words ->
words.sum(0) {
counts.get(it, []).size()
}
}
def mPoints = getPoints(["mr.", "he", "him", "his"])
def fPoints = getPoints(["mrs.", "ms.", "miss", "she", "her", "hers"])
mPoints == fPoints ? "unknown" : mPoints > fPoints ? "male" : "female"
}
--->
</cfoutput>