SwoopSearch / pyaddress

pyaddress is an address parsing library, taking the guesswork out of using addresses in your applications. We use it as part of our apartment search and apartment spider applications.
BSD 3-Clause "New" or "Revised" License
99 stars 43 forks source link

Unable to parse 5-digit-long house number in street address #2

Closed jialing3 closed 11 years ago

jialing3 commented 11 years ago
In [17]: ap = AddressParser()

In [18]: ap.parse_address('5169 North Scottsdale Road')
Out[18]: Address - House number: 5169 Prefix: N. Street: Scottsdale Suffix: Rd. Apartment: None City,State,Zip: None, None None

In [19]: ap.parse_address('51691 North Scottsdale Road')

InvalidAddressException                   Traceback (most recent call last)
/home/xxx/<ipython-input-19-a178d7194cb2> in <module>()
----> 1 ap.parse_address('51691 North Scottsdale Road')

/usr/local/lib/python2.7/dist-packages/address/address.pyc in parse_address(self, address, line_number)
     86         loaded suffixes, cities, etc.
     87         """
---> 88         return Address(address, self, line_number, self.logger)
     89 
     90     def dstk_multi_address(self, address_list):

/usr/local/lib/python2.7/dist-packages/address/address.pyc in __init__(self, address, parser, line_number, logger, dstk_pre_parse)
    190 
    191         if self.house_number is None or self.house_number <= 0:
--> 192             raise InvalidAddressException("Addresses must have house numbers.")
    193         elif self.street is None or self.street == "":
    194             raise InvalidAddressException("Addresses must have streets.")

InvalidAddressException: Addresses must have house numbers.
jialing3 commented 11 years ago

The check for zipcode seems to be the cause of the problem. My work-around is to add a dummy '00000' zipcode to the input. Perhaps a future version could include a zip=None option?

In [38]: ap.parse_address('51691 North Scottsdale Road, 00000')
Out[38]: Address - House number: 51691 Prefix: N. Street: Scottsdale Suffix: Rd. Apartment: None City,State,Zip: None, None 00000