public RegexCache(IAbbreviations abbreviations) { _abbreviations = abbreviations; _regexDictionary = new Dictionary <string, Regex> { { "direction", new Regex(@"\b(north|n\.?)(?!\w)|\b(south|s\.?)(?!\w)|\b(east|e\.?)(?!\w)|\b(west|w\.?)(?!\w)", RegexOptions.IgnoreCase | RegexOptions.Compiled) }, { "directionSubstitutions", new Regex(@"\b((so|sou|sth)|(no|nor|nrt)|(ea|eas|est)|(we|wst|wes))(?=\s|\.|$)", RegexOptions.IgnoreCase | RegexOptions.Compiled) }, { "streetType", BuildStreetTypeRegularExpression() }, { "unitType", new Regex(BuildUnitTypeRegularExpression(), RegexOptions.IgnoreCase | RegexOptions.Compiled) }, { "unitTypeLookBehind", new Regex(BuildUnitTypeRegularExpression() + @"(?:\s?#)", RegexOptions.IgnoreCase | RegexOptions.Compiled) }, { "highway", new Regex(@"\b(sr|state route|us|Highway|hwy|u.s\.?)(?!\w)", RegexOptions.IgnoreCase | RegexOptions.Compiled) }, { "separateNameAndDirection", new Regex(@"\b(\d+)(s|south|e|east|n|north|w|west)\b", RegexOptions.IgnoreCase | RegexOptions.Compiled) }, { "streetNumbers", new Regex(@"\b(?<!-#)(\d+)", RegexOptions.Compiled) }, { "ordinal", new Regex(@"^(\d+)(?:st|nd|rd|th)\b", RegexOptions.IgnoreCase | RegexOptions.Compiled) }, { "pobox", new Regex(@"p\s*o\s*box\s*(\d+)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase) }, { "zipPlusFour", new Regex(@"(^\d{5})-?(\d{4})?$", RegexOptions.Compiled) }, { "cityName", new Regex(@"^[ a-z\.]+", RegexOptions.Compiled | RegexOptions.IgnoreCase) }, { "cityTownCruft", new Regex(@"(?:city|town)(?: of)", RegexOptions.Compiled | RegexOptions.IgnoreCase) }, { "avesOrdinal", BuildOridnalRegex() } }; }
public Handler(IRegexCache regexCache, IAbbreviations abbreviations, ILogger log) { _regexCache = regexCache; _abbreviations = abbreviations; _log = log; }
public ParseAddressCommand(IRegexCache regexCache, IAbbreviations abbreviations) { _regexCache = regexCache; _abbreviations = abbreviations; }