Skip to content

Instantly share code, notes, and snippets.

View namsor's full-sized avatar

NamSor namsor

View GitHub Profile
@namsor
namsor / gist:fe7c93f3d722d9597c3ae22b9a204114
Created July 4, 2019 06:57
R example : appending gender to a CSV file using NamSor batch API
library(namsor)
setwd("D:/Sync/Dropbox/NamSor_CarmenAguilarGarcia/")
names<-read.csv("combine.csv",header = F)
str(names)
names$V1<-as.character(names$V1)
names$V2<-as.character(names$V2)
names$V3<-as.character(names$V3)
from __future__ import print_function
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: api_key
configuration = openapi_client.Configuration()
configuration.api_key['X-API-KEY'] = '<your API key>'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
@namsor
namsor / gist:cf026ab5cca36343e63092fb77bd6e0d
Created May 24, 2018 11:56
jQuery : Inferring Origin of a Personal Name using NamSor API and Cross-Origin Resource Sharing (CORS)
// Submit the form using AJAX.
$.ajax({
type: 'GET',
url: 'https://api.namsor.com/onomastics/api/json/origin/Elena/Rossini',
//contentType: 'text/json',
xhrFields: {
// The 'xhrFields' property sets additional fields on the XMLHttpRequest.
// This can be used to set the 'withCredentials' property.
// Set the value to 'true' if you'd like to pass cookies to the server.
// If this is enabled, your server must respond with the header
@namsor
namsor / gist:bc1549c209c1ffcb3ffdc9f399fa917f
Created May 24, 2018 11:53
jQuery : Inferring Gender of a Personal Name using NamSor API and Cross-Origin Resource Sharing (CORS)
// Submit the form using AJAX.
$.ajax({
type: 'GET',
url: 'https://api.namsor.com/onomastics/api/json/gender/John/Smith',
//contentType: 'text/json',
xhrFields: {
// The 'xhrFields' property sets additional fields on the XMLHttpRequest.
// This can be used to set the 'withCredentials' property.
// Set the value to 'true' if you'd like to pass cookies to the server.
// If this is enabled, your server must respond with the header
@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:2fad2880dc1d0127c580
Last active August 29, 2015 13:57
wget call to Gendre API inferring gender from a personal name
# Jean Smith is more likely a female name in the US
wget -q -O - http://api.onomatic.com/onomastics/api/gendre/Jean/Smith/us
0.9
# Jean Valjean is a male name in France
wget -q -O - http://api.onomatic.com/onomastics/api/gendre/Jean/Valjean/fr
-1.0
# Olga Sokolova is a female name
wget -q -O - http://api.onomatic.com/onomastics/api/gendre/Olga/Sokolova
@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)