I don't deal with addressing much... what little bit I had to deal with frustrated me to no end... there are no one standard for addressing so the last word in the string may not be the street type, could be a range, box number ..... so if you are looking to pull out the street type, street name ect.... what you need is a more comprehensive app to do so; an address parser..... that said... I did have some luck with an old parsing python script I found and modified slightly to fit my needs... as you can see it is more involved than the simple field calculator scripts and still at least for the Miami area is only 90% effective in parsing.... I do not remember the source of the original script so my apologies to the person who hard effort went in making it.
from pyparsing import *
def ParseAddress(address):
units = oneOf("Zero One Two Three Four Five Six Seven Eight Nine Ten"
"Eleven Twelve Thirteen Fourteen Fifteen Sixteen Seventeen Eighteen Nineteen",
caseless=True)
tens = oneOf("Ten Twenty Thirty Forty Fourty Fifty Sixty Seventy Eighty Ninety",caseless=True)
hundred = CaselessLiteral("Hundred")
thousand = CaselessLiteral("Thousand")
OPT_DASH = Optional("-")
numberword = ((( units + OPT_DASH + Optional(thousand) + OPT_DASH +
Optional(units + OPT_DASH + hundred) + OPT_DASH +
Optional(tens)) ^ tens )
+ OPT_DASH + Optional(units) )
housenumber = originalTextFor( numberword | Combine(Word(nums) +
Optional(OPT_DASH + oneOf(list(alphas))+FollowedBy(White()))) +
Optional(OPT_DASH + "1/2")
)
numberSuffix = oneOf("st th nd rd").setName("numberSuffix")
streetnumber = originalTextFor( Word(nums) +
Optional(OPT_DASH + "1/2") +
Optional(numberSuffix) )
name = ~numberSuffix + Word(alphas)
type_ = Combine( MatchFirst(map(Keyword,"ST BLVD LN RD AVE PASS "
"TRL PATH PSGE WAY LANE"
"CIR DR PKWY CT SQ "
"LP TER TERR PL".split())) + Optional(".").suppress())
nsew = Combine(oneOf("N S E W North South East West NW NE SW SE") + Optional("."))
streetName = (Combine( Optional(nsew) + streetnumber +
Optional("1/2") +
Optional(numberSuffix), joinString=" ", adjacent=False )
^ Combine(~numberSuffix + OneOrMore(~type_ + Combine(Word(alphas) + Optional("."))), joinString=" ", adjacent=False)
^ Combine("Avenue" + Word(alphas), joinString=" ", adjacent=False)).setName("streetName")
acronym = lambda s : Regex(r"\.?\s*".join(s)+r"\.?")
poBoxRef = ((acronym("PO") | acronym("APO") | acronym("AFP")) +
Optional(CaselessLiteral("BOX"))) + Word(alphanums)("boxnumber")
streetReference = streetName.setResultsName("name") + Optional(type_).setResultsName("type")
direct = housenumber.setResultsName("number") + streetReference
intersection = ( streetReference.setResultsName("crossStreet") +
( '@' | Keyword("and",caseless=True)) +
streetReference.setResultsName("street") )
streetAddress = ( poBoxRef("street")
^ direct.setResultsName("street")
^ streetReference.setResultsName("street")
^ intersection )
suiteRef = (
oneOf("Suite Ste Apt Apartment Room Rm
Optional(".") +
Word(alphanums+'-')("suitenumber"))A
streetAddress = streetAddress + Optional(Suppress(',') + suiteRef("suite"))
return streetAddress.parseString(address, parseAll=True)
a = ParseAddress("611 NW 23 CT")
print a
print "Number: " + a.street.number
print "Name : " + a.street.name
print "Type : " +a.street.type
print
print "-----------"
if a.street.boxnumber:
print "Box:", addr.street.boxnumber
print a.dump