Skip to content

Instantly share code, notes, and snippets.

View namsor's full-sized avatar

NamSor namsor

View GitHub Profile
@namsor
namsor / Extract Gender
Last active August 29, 2015 14:06
Python API wrapper to determine the gender of a personal name
# use hammock from https://github.com/kadirpekel/hammock
from hammock import Hammock as GendreAPI
gendre = GendreAPI("http://api.namsor.com/onomastics/api/json/gendre")
# example call to GendRE API, will automatically recognize country/culture and return gender
resp = gendre('Jean','Parker').GET()
print (resp.json().get('gender'))
# returns: female
# gendre('Jean','Marchand') would return 'male'
@namsor
namsor / gist:9676522
Last active August 29, 2015 13:57
API call to predict gender from a personal name (Gendre API sample)
import java.net.URLEncoder;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
/**
* Predict Gender from a Personal name
* @param firstName The given name
* @param lastName The family name
* @return Double in range -1 (male) .. +1 (female)