Pyap

Fast Python library for detecting and parsing addresses from free text

Library
PyPI
v0.3.1
213stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
34/100Needs Attention
Development Activity0
Maintenance0
Community56
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture70
Code Quality68
Innovation64
Learning Curve88

Pyap is an MIT-licensed text-processing library for Python that detects and parses postal addresses out of free-form text. It currently supports US, Canadian, and British address formats, returning matched addresses that can be inspected as structured dictionaries of their component parts.

Built on regular expressions rather than lookup tables or machine learning, Pyap is designed for speed: it can find addresses in large volumes of text in real time with low error rates, making it a practical open-source alternative to proprietary or pay-per-use address-detection services.

What You Get

  • Address detection and parsing from free-form text with a single pyap.parse() call
  • Support for US, Canadian, and British address formats via a country argument
  • Structured access to address components through address.as_dict()
  • Regex-based matching that runs fast enough for real-time, high-volume processing
  • A dependency-light, MIT-licensed pure-Python package

Common Use Cases

  • Extracting addresses from web pages while crawling or scraping
  • Detecting addresses inside large text corpora in real time
  • Pulling structured address parts out of unstructured documents
  • Pre-filtering text for addresses before running slower geocoding

Under The Hood

Architecture - Pyap is built around per-country address grammars expressed as regular expressions. pyap.parse(text, country=...) selects the appropriate country module, scans the input for substrings matching the address pattern, and returns address objects whose named regex groups (street number, street name, city, state, postal code) are surfaced through as_dict(). Because matching is purely pattern-based and context-free, detection is fast but deliberately avoids city or street-name lookup tables.

Tech Stack - The package is pure Python with a minimal dependency footprint, distributed on PyPI under the MIT license. Country support is modular, so adding a new locale (e.g. the noted future French rules) means adding a new regex ruleset.

Code Quality - The project is small and mature but currently low-activity (last pushed in 2023), with a handful of contributors. Its correctness trade-offs are documented candidly in the README, including the known false-positive cases inherent to regex-only detection.

API Design - The API is about as simple as possible: one parse function, a country keyword, and an as_dict() accessor on each result. That minimalism makes it trivial to adopt, at the cost of limited configurability — tuning accuracy generally means reverifying results downstream (e.g. via geocoding) rather than adjusting the parser.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search