mjfii / r-nameparser-lib Goto Github PK
View Code? Open in Web Editor NEWAn R library allowing parsing of surname, first name, and gender based on US census data.
License: GNU Affero General Public License v3.0
An R library allowing parsing of surname, first name, and gender based on US census data.
License: GNU Affero General Public License v3.0
I have been getting the following error:
x <- 'livingston III, Mr. MICHAEL JOHN9'
parse.names(x)
Error in checkForRemoteErrors(val) :
one node produced an error: object 'census.names' not found
It looks like the census.names data frame was not accessible in the clusters. The code failed during parLapply()
.
After reading this explanation: SimDesign Vignette
I was able to fix it by updating the parse.names()
function by loading census.names in the function and exporting it to the clusters with parallel::clusterExport( cl=cl, 'census.names' )
. Wanted to share in case others were having this issue.
function (x, ...)
{
data("census.names")
no_cores <- parallel::detectCores() - 1
cl <- parallel::makeCluster(no_cores)
parallel::clusterExport( cl=cl, 'census.names' )
input_names <- data.frame(name = x)
input_names$parsed_name <- parallel::parLapply(cl, input_names$name,
parse.name)
input_names <- data.frame(input_names$name, do.call("rbind",
strsplit(as.character(input_names$parsed_name), "|",
fixed = TRUE)), stringsAsFactors = FALSE)
colnames(input_names) <- c("name", "salutation", "first_name",
"middle_name", "last_name", "suffix", "gender", "gender_confidence")
parallel::stopCluster(cl)
return(input_names)
}
To pass custom prefixes and suffixes to parse.name()
through the parse.names()
function the elipses need to be added to parLapply()
:
input_names$parsed_name <- parallel::parLapply(cl, input_names$name,
parse.name, ...)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.