Skip to main content

Pyap is an MIT Licensed text processing library, written in Python, 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 Pyap, simply:

$ pip install pyap

About

This library has been created because i couldn’t find any reliable and opensource solution for detecting addresses on web pages when writing my web crawler. Currently available solutions have drawbacks when it comes to using them to process really large amounts of data fast. You’ll either have to buy some proprietary software; use third-party pay-per-use services or use address detecting which is slow and unsuitable for real-time processing.

Pyap is an alternative to all these methods. It is really fast because it is based on using regular expressions and it allows to find addresses in text in real time with low error rates.

Future work

  • Add rules for parsing FR addresses

  • …

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.

To achieve the most accuracy Pyap results could be reverified using geocoding process.

Limitations

Because 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.

Metadata

Release files for pyap 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyap 0.3.1
File Size Uploaded
pyap-0.3.1.tar.gz 24.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyap 0.3.1
File Interpreter ABI Platform
pyap-0.3.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 52.7 kB

Release files / pyap-0.3.1.tar.gz

Download URL pyap-0.3.1.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
372ea7b6364a3d2c75ffb26ebbe269ce44d71b48620d57630548bc263a6691db
BLAKE2b-256 checksum
How to use checksums
80c111817334122325663f739f84864b1cca74f49e263d26f2cbcc2a651146f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/2.7.16 Darwin/18.7.0

Release files / pyap-0.3.1-py2.py3-none-any.whl

Download URL pyap-0.3.1-py2.py3-none-any.whl
Size 28.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d0b0440826fd2bb46018b8e4182cc7b79fbfcb3026f7d32c97384c0c362210c6
BLAKE2b-256 checksum
How to use checksums
53b2f0f962a5385d54cd91c153df93932b4996b793f1a2145807823d7f71328d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/2.7.16 Darwin/18.7.0

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page