GenderGuesser

An R package for using the genderize.io API to guess the gender of names.
git clone https://git.eamoncaddigan.net/GenderGuesser.git
Log | Files | Refs | README | LICENSE

getCountryAndLanguageCodes.R (1104B)


      1 
      2 # Read genderize.io's lists of supported country and language codes -------
      3 
      4 queryResult <- httr::GET("https://api.genderize.io/languages",
      5                          httr::config(ssl_verifypeer = FALSE))
      6 if (httr::status_code(queryResult) == 200) {
      7   responseFromJSON <- jsonlite::fromJSON(httr::content(queryResult, as="text"))
      8   genderizeLanguages <- responseFromJSON[["languages"]]
      9   # Don't know why they return an empty string.
     10   genderizeLanguages <- genderizeLanguages[nchar(genderizeLanguages) > 0]
     11 } else {
     12   stop("Couldn't load language list")
     13 }
     14 
     15 queryResult <- httr::GET("https://api.genderize.io/countries",
     16                          httr::config(ssl_verifypeer = FALSE))
     17 if (httr::status_code(queryResult) == 200) {
     18   responseFromJSON <- jsonlite::fromJSON(httr::content(queryResult, as="text"))
     19   genderizeCountries <- responseFromJSON[["countries"]]
     20 } else {
     21   stop("Couldn't load country list")
     22 }
     23 
     24 
     25 # Save the lists ----------------------------------------------------------
     26 
     27 devtools::use_data(genderizeLanguages, genderizeCountries,
     28                    internal = TRUE, overwrite = TRUE)