jamesrcounts/usaddress

Incorrect Handling of Null Secondary Unit

Opened this issue · 1 comments

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

public Dictionary<string, string> RangedUnits { get; } = new Dictionary<string, string>

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.