pyap: Python Address Parser

0.3.1 · maintenance · verified Thu Apr 16

Pyap is an MIT Licensed text processing library, written in Python, for detecting and parsing addresses using regular expressions. It currently supports US, Canadian, and British address formats. The library is at version 0.3.1, with its last release in September 2020, indicating a slow release cadence or maintenance status for the original package, though forks exist.

Common errors

Warnings

Install

Imports

Quickstart

The quickstart demonstrates how to import the `pyap` library and use its `parse` function to extract addresses from a given text string. It highlights specifying the `country` parameter for accurate parsing and iterating through the results to access both the full address string and its parsed components as a dictionary.

import pyap

text_with_address = """This is some sample text containing an address: 225 E. John Carpenter Freeway, Suite 1500 Irving, Texas 75062. And more text."""

# Parse addresses for the US
addresses = pyap.parse(text_with_address, country='US')

for address in addresses:
    print(f"Found Address: {address}")
    print(f"Parsed Components: {address.as_dict()}")

# Example with a different country (Canada)
canada_address_text = """Meeting at 4998 Stairstep Lane Toronto ON, tomorrow."""
canada_addresses = pyap.parse(canada_address_text, country='CA')
for address in canada_addresses:
    print(f"Found Canadian Address: {address}")

view raw JSON →