Skip to main content

Pyap2 is a maintained fork of pyap, a regex-based library for parsing US, CA, and UK addresses. The fork adds typing support, handles more address formats and edge cases.

Project description

Pyap2 is a maintained fork of Pyap, a regex-based python library for detecting and parsing addresses. Currently it supports US 🇺🇸, Canadian 🇨🇦 and British 🇬🇧 addresses.

>>> import pyap
>>> test_address = """
    Lorem ipsum
    225 E. John Carpenter Freeway,
    Suite 1500 Irving, Texas 75062
    Dorem sit amet
    """
>>> addresses = pyap.parse(test_address, country='US')
>>> for address in addresses:
        # shows found address
        print(address)
        # shows address parts
        print(address.as_dict())
...

Installation

To install Pyap2, simply:

$ pip install pyap2

About

We started improving the original pyap by adopting poetry and adding typing support. It was extensively tested in web-scraping operations on thousands of US addresses. Gradually, we added support for many rarer address formats and edge cases, as well as the ability to parse a partial address where only street info is available.

Typical workflow

Pyap should be used as a first thing when you need to detect an address inside a text when you don’t know for sure whether the text contains addresses or not.

Limitations

Because Pyap2 (and Pyap) is based on regular expressions it provides fast results. This is also a limitation because regexps intentionally do not use too much context to detect an address.

In other words in order to detect US address, the library doesn’t use any list of US cities or a list of typical street names. It looks for a pattern which is most likely to be an address.

For example the string below would be detected as a valid address: “1 SPIRITUAL HEALER DR SHARIF NSAMBU SPECIALISING IN”

It happens because this string has all the components of a valid address: street number “1”, street name “SPIRITUAL HEALER” followed by a street identifier “DR” (Drive), city “SHARIF NSAMBU SPECIALISING” and a state name abbreviation “IN” (Indiana).

The good news is that the above mentioned errors are quite rare.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyap2-0.1.8.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

pyap2-0.1.8-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file pyap2-0.1.8.tar.gz.

File metadata

  • Download URL: pyap2-0.1.8.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyap2-0.1.8.tar.gz
Algorithm Hash digest
SHA256 026fd51917535bac78a0fc93f5ea60396f3f9dd89fa6998d8696100622cfe1ff
MD5 d0bcf3ad2b7023a4cf15f89645c8a9fa
BLAKE2b-256 9be90c23b633ba99a4afb84666e8065984a3978a27185ab64a6a7992bba09879

See more details on using hashes here.

File details

Details for the file pyap2-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: pyap2-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyap2-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 037975a93748d79ed8afcfcb3ae518dbc291640fb68bae14c5d5bd17f479baa9
MD5 4e15f1cc567fdf16304fce5a0442781b
BLAKE2b-256 e5d44971e989f49a8aff8badd6ca3d0c497f2826961d40f1dd2969696d4b6269

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page