TL;DR
- Use fuzzy string matching to account for spelling mistakes.
- Solving
Jennifer
for Alice
will require you to know where to look in your DB for these cases, or talk to make a better Excel file to force people to only input first names (e.g. make a an entry to a cell restricted to a given list).
Fuzzy String Matching
In R, you can use adist
or the stringdist
package. These can be used to measure the distance from an entry (e.g. Aalice
to a list of potential matches [Alice, Bianca, Chris]
.
Here is an articles explaining how to use both.
An extract from the article:
source1.devices<-read.csv('[path_to_your_source1.csv]')
source2.devices<-read.csv('[path_to_your_source2.csv]')
# To make sure we are dealing with charts
source1.devices$name<-as.character(source1.devices$name)
source2.devices$name<-as.character(source2.devices$name)
# It creates a matrix with the Standard Levenshtein distance between the name fields of both sources
dist.name<-adist(source1.devices$name,source2.devices$name, partial = TRUE, ignore.case = TRUE)
# We now take the pairs with the minimum distance
min.name<-apply(dist.name, 1, min)
match.s1.s2<-NULL
for(i in 1:nrow(dist.name))
{
s2.i<-match(min.name[i],dist.name[i,])
s1.i<-i
match.s1.s2<-rbind(data.frame(s2.i=s2.i,s1.i=s1.i,s2name=source2.devices[s2.i,]$name, s1name=source1.devices[s1.i,]$name, adist=min.name[i]),match.s1.s2)
}
# and we then can have a look at the results
View(match.s1.s2)
All this assumes that you have a list of names that are actually valid.