public PrefixStreetTypeFinder(AddressParseContainer container) : base(container) { fullPrefixMatches = new List <AddressPartResult>(); firstPrefixMatches = new List <AddressPartResult>(); secondPrefixMatches = new List <AddressPartResult>(); }
public NormalStreetTypeFinder( AddressParseContainer container, IEnumerable <StreetType> streetTypes) : base(container) { possibleFullStreetTypes = new List <AddressPartResult>(); possibleAbbreviatedStreetTypes = new List <AddressPartResult>(); allPossibleStreetTypes = new List <AddressPartResult>(); this.streetTypes = streetTypes.ToList(); }
public NonPhysicalStreetTypeFinder(AddressParseContainer container) : base(container) { }
public AddressNumberFractionFinder(AddressParseContainer container) : base(container) { possibleMatches = new List <AddressPartResult>(); }
public DirectionalPrefixFinder(AddressParseContainer container) : base(container) { }
public StateFinder(AddressParseContainer container) : base(container) { possibleMatches = new List <AddressPartResult>(); }
public AddressSplitter(AddressParseContainer container) { this.container = container; }
public Address Parse( string addressToParse, string city = null, string state = null, string postalCode = null) { if (string.IsNullOrWhiteSpace(addressToParse)) { throw new AddressParsingException($"{nameof(addressToParse)} is blank."); } this.addressToParse = addressToParse; container = new AddressParseContainer(this.addressToParse); var splitter = new AddressSplitter(container); splitter.SplitAndClean(); // Find Required Things new NonPhysicalStreetTypeFinder(container).Find(); new PhysicalPrefixStreetTypeFinder(container).Find(); new NormalStreetTypeFinder(container, StreetTypes()).Find(); new StreetTypeStreetNameFinder(container, StreetTypes()).Find(); VerifyThatStreetTypeIsSet(); new AddressNumberFinder(container).Find(); new UnitTypeFinder(container).Find(); if (string.IsNullOrWhiteSpace(postalCode)) { new PostalCodeFinder(container).Find(); } else { if (Regex.IsMatch(postalCode, @"^(\d{5,})\-(\d{4,})$")) { container.ParsedAddress.PostalCode = new AddressPartResult() { Index = int.MaxValue - 1, Value = postalCode.Split('-')[0] }; container.ParsedAddress.PostalCodeExt = new AddressPartResult() { Index = int.MaxValue, Value = postalCode.Split('-')[1] }; } else { container.ParsedAddress.PostalCode = new AddressPartResult() { Index = int.MaxValue - 1, Value = postalCode }; } } if (string.IsNullOrWhiteSpace(state)) { new StateFinder(container).Find(); } else { container.ParsedAddress.State = new AddressPartResult() { Index = int.MaxValue - 2, Value = state }; } new DirectionalPrefixFinder(container).Find(); new DirectionalSuffixFinder(container).Find(); // Find things in between other things new AddressNumberFractionFinder(container).Find(); new StreetNameFinder(container).Find(); new UnitNumberFinder(container).Find(); if (string.IsNullOrWhiteSpace(city)) { new CityFinder(container).Find(); } else { container.ParsedAddress.City = new AddressPartResult() { Index = int.MaxValue - 3, Value = city }; } //new AddressNumberFractionFinder(container).Find(); new PostalCodeExtFinder(container).Find(); CopyParsedAddressResultsToAddress(); return(container.Address); }
public PhysicalPrefixStreetTypeFinder(AddressParseContainer container) : base(container) { }
public StreetTypeStreetNameFinder( AddressParseContainer container, IEnumerable <StreetType> streetTypes) : base(container) { this.streetTypes = streetTypes.ToList(); }
public PostalCodeExtFinder(AddressParseContainer container) : base(container) { possibleMatches = new List <AddressPartResult>(); }