This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |