usaddress
usaddress copied to clipboard
Incorrect Handling of Null Secondary Unit
I've tried to take a stab at fixing this, but I am not skilled enough at RegEx to solve it...
If i understand the USPS spec correctly, the secondary unit is allowed to be null - so when passed an address like:
3330 W SIGNAL PEAK DR RP303
Expected Behavior would be: Number: 3330 Predirectional: W Street: SIGNAL PEAK Suffix: DR SecondaryUnit: string.Empty SecondaryNumber: RP303
Actual Behavior is: Number: 3330 Predirectional: W Street: SIGNAL PEAK DR RP303 Suffix: string.Empty SecondaryUnit: string.Empty SecondaryNumber: string.Empty
You might be able to solve by adding RP to the RangedUnit dictionary https://github.com/jamesrcounts/usaddress/blob/1ca28c527e6271f2ca9da60529167a8879f4632d/src/AddressParser/AddressParser.cs#L257
But yes, finding a generic solution may be difficult for you if your addresses really don't include City, State and Zip. There is a lot less to go on. You might consider writing a secondary processor to massage the results after the initial pass from this library.