Package: compare-strings
CompareStringsCompareStrings accepts either two strings or two Pandas Series' containing
strings, as inputs, and provides a simple way to tell how similar or dissimilar
two strings are.By default, thecompare_stringsfunction returns the Levenshtein Distance
between the strings, divided by the length of the first string, where 0
represents absolute similiarity, higher values represent increasing
dissimilarity.Optional argumentmethodallows selection of alternative methods of
calculation, such as the absolute Levenshtein distance -method = lev_abs,
or the cosine distance (not yet released).CompareStrings by default stripes numeric and punctuation characters from the
string before performing the calculation.The optionalemailargument takes 1 or 2 as values, and indicates to the
function that either string (or series) 1 or 2 contain an email address. When
this argument is used, the input that contains an email address is split on
the '@' and the email domain is discarded before the calculation is performed.Theprecisionargument is used to determine the number of decimals returns
in the resulting float.InstallationpipinstallCompareStringsUsageStrings:compare_stringssupports indivdual strings as inputs. Examples:fromCompareStringsimportcompare_stringsmethod='lev_abs'# Levenshtein Distancecompare_strings('string one','string',method='lev_abs')Out[1]: 4There were 4 additions, deletions or substitutions required to change the first
string into the secondmethod='lev_props'# Levenshtein Distance as a proportion of the length of the first stringcompare_strings('string one','string',method='lev_props')Out[1]: 0.4There were 4 additions, deletions or substitutions required to change the first
string into the second string, and 10 characters in the first string.Pandas Series:compare_stringsalso accepts pandas series as inputs. It will return a new
DataFrame containing the inputs and a new column with the output.Theemailargument can be used to tell the function if one of the inputs
contains an email address, and performs some preprocessing to remove the
domain - for example:Withoutemailset:emailfull_namelevenshtein_proportions6203tom_johnson1@hotmail.comTom  Jonhson0.468990suzanne_stevenson54@hotmail.comSuzanne  stevenson0.436769marie.eriksson99@hotmail.comAnn  Eriksson0.622552elisabeth.henriksson8@hotmail.comElisabeth  Henriksson0.38Withemail = 1set:emailfull_namelevenshtein_proportions6203tom_jonson1@hotmail.comTom  Jonson08990suzanne_stevenson54@hotmail.comSuzanne  Stevenson06769marie.eriksson99@hotmail.comAnn  Eriksson0.292552elisabeth.henriksson8@hotmail.comElisabeth  Henriksson0Passing1to theemailargument tells the function to ignore the characters
after and including the '@' in the first column when performing the calculation.check_names:Thecheck_namesargument is intended to be used in conjunction with theemailargument. It adds another column to the returned DataFrame with aTrueorFalsevalue, indicating whether any part of the string was found in thebig_names_list. For example, it may be useful to ignore the similarity score
if the email address passed into the function does not contain anything
recognised as a name.Disclaimerthe names list currently contains 7.6k first and surnames from a
number of nationalities, but  is in no way exhaustive. It also contains some
names that are quite short, and may return false positives if those short
strings are found in the inputs.Coming soon:Support for additional alternative measures of similarity/dissimilaritySupport for lists as inputsProbably other stuff - want to help? See belowContributionThis is my very first python package so contributions are very much welcome.
Suggestions include:Documentation incl. tidying up docstrings and commentsAdditions to the big_names_listSupport for names in other languagesNew similarity measuresSupport or suggestions for other use cases