Pages

Twenital: Determines gender from a twitter handle

Twitter never stores the gender of their users. It makes the life of analytic engines very difficult to find that what is the ratio of men vs women on twitter.
Here I have created quick and dirty mash-up to get  gender of the twitter user.


How It Works?
Thanks to face.com API, they have recently released face recognition API. I am simply using their face recognition API to do this.


Here is AJAX code

function getusergender(imageurl) {
var url = 'http://api.face.com/faces/detect.json?api_key=1ce92a4c5e60f04c37bedf86c2d19387&urls=' + imageurl + '&callback=?';
$.getJSON(url, function (data) {
if (data.status == "success") {
if (data.photos[0].tags.length == 0) {
$("#resdiv").html('<div class="errormsg">hmmm..Let him/her put better profile picture. </b>TIP: put high resolution profile picture, facing front.</div>');
}
else if (data.photos[0].tags.length > 1) {
showerror('This user is multifaceted, Let him/her put better profile picture..');
}
else {
if (data.photos[0].tags[0].attributes.gender.value) {
var gender = data.photos[0].tags[0].attributes.gender.value;
if (data.photos[0].tags[0].attributes.gender.confidence > 40) {
if (gender == 'male') {
$("#resdiv").text('100% Male');
}
else {
$("#resdiv").text('Gorgeous Female');
}

}
else {
if (gender == 'male') {
$("#resdiv").text('Male');
}
else {
$("#resdiv").text('Female');
}
}
}
else {
showerror('hmmm... not sure!!');
}

}
}
else {
if (data.usage.used > 197) {
showerror('Sorry!! Application Overloaded!!');
}
else {
showerror('Processing failed!! Can not determine gender!!');
}
}
});

}

   DEMO  

1 comment:

  1. Hi ,
    This is a good one.
    What i like most is if confidence > 40 then it is 100% male/ gorgeous female....... should it not be >60 ;)

    This will surely disappoint those whose DP is of some famous faces of different gender :) :) :) :)

    regards,
    amit kumar

    ReplyDelete

Your comment will inspire me, Please leave your comment