public static string CleanAddress(string address) { if (address == "UNKNOWN" || address == "UNKOWN" || address == "UNK" || address == "XXX" || address.StartsWith("UNABL") ) { return(""); } if (address == "HOMELESS" || address == "UNDOMICILED" || address == "UNDOMICILE" || address == "H O M E L E S S") { return("HOMELESS"); } List <Tuple <string, string> > suffixes = AddressSuffixLoader.GetStreetSuffixAbbreviationTuples(); string cleaned = address.ToUpper().Replace(" WEST ", " W ").Replace(" EAST ", " E ").Replace(" NORTH ", " N ").Replace(" SOUTH ", " S ").Replace(" SO ", " S "); cleaned = Regex.Replace(cleaned, @"(\d)(ST|ND|RD|TH)\b", "$1"); for (int c = 0; c < suffixes.Count; c++) { Tuple <string, string> suffix = suffixes[c]; if (cleaned.EndsWith(suffix.Item1)) { cleaned = cleaned.Replace($" {suffix.Item1}", $" {suffix.Item2}"); } } return(cleaned); }
public static bool BasedOnAddressSoftMatch(SplittingQuestion question, string column1, string column2) { bool passedSoftMatch = false; string[] address1Bits = column1.Split(' '); string[] address2Bits = column2.Split(' '); if (address1Bits.Length > 1 && address2Bits.Length > 1) { List <string> matches = new List <string>(); string[] suffixes = AddressSuffixLoader.GetAllStreetSuffixes(); bool integerFound = false; foreach (string address1Bit in address1Bits) { foreach (string address2Bit in address2Bits) { if (address1Bit == address2Bit && !matches.Contains(address1Bit) && !suffixes.Contains(address1Bit)) { matches.Add(address1Bit); int throwAway = 0; if (int.TryParse(address1Bit, out throwAway)) { integerFound = true; } } } } passedSoftMatch = (matches.Count >= 2 && integerFound); } return(passedSoftMatch); }