{"id":9204,"library":"pyap","title":"pyap: Python Address Parser","description":"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.","status":"maintenance","version":"0.3.1","language":"en","source_language":"en","source_url":"https://github.com/vladimarius/pyap","tags":["address parsing","text processing","regex","geocoding","utility"],"install":[{"cmd":"pip install pyap","lang":"bash","label":"Install pyap"}],"dependencies":[],"imports":[{"symbol":"pyap","correct":"import pyap"}],"quickstart":{"code":"import pyap\n\ntext_with_address = \"\"\"This is some sample text containing an address: 225 E. John Carpenter Freeway, Suite 1500 Irving, Texas 75062. And more text.\"\"\"\n\n# Parse addresses for the US\naddresses = pyap.parse(text_with_address, country='US')\n\nfor address in addresses:\n    print(f\"Found Address: {address}\")\n    print(f\"Parsed Components: {address.as_dict()}\")\n\n# Example with a different country (Canada)\ncanada_address_text = \"\"\"Meeting at 4998 Stairstep Lane Toronto ON, tomorrow.\"\"\"\ncanada_addresses = pyap.parse(canada_address_text, country='CA')\nfor address in canada_addresses:\n    print(f\"Found Canadian Address: {address}\")","lang":"python","description":"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."},"warnings":[{"fix":"For new projects or enhanced capabilities, evaluate `pyap2` (or other forks) instead of the original `pyap` package. If staying with `pyap`, be aware of potential lack of updates.","message":"The original `pyap` library (v0.3.1) has not been updated since September 2020. For more active maintenance, typing support, and handling of additional address formats/edge cases, consider using community-maintained forks like `pyap2` (`pip install pyap2`).","severity":"deprecated","affected_versions":"<=0.3.1"},{"fix":"Always post-validate parsed addresses, especially for critical applications. Consider integrating with a geocoding service to verify the existence and accuracy of detected addresses.","message":"Pyap is solely based on regular expressions and does not validate addresses against external databases or lists of cities/street names. This can lead to false positives where strings that *look* like addresses are parsed, even if they are not real-world locations (e.g., '1 SPIRITUAL HEALER DR SHARIF NSAMBU SPECIALISING IN' might be detected).","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure you always pass a `country` argument (e.g., `country='US'`, `country='CA'`, `country='GB'`) to `pyap.parse()`. Consult the documentation or source code for the exact list of supported country codes.","message":"The `country` parameter in `pyap.parse()` is mandatory. Failing to provide a supported country code will result in an exception.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Always specify the `country` parameter, e.g., `pyap.parse(text, country='US')`.","cause":"The `pyap.parse()` function was called without the required `country` argument.","error":"pyap.exceptions.NoCountrySelected: No country specified during library initialization."},{"fix":"Use one of the supported country codes: 'US' (United States), 'CA' (Canada), or 'GB' (Great Britain). For other countries, this library does not provide support.","cause":"An unsupported or incorrect country code was provided to `pyap.parse()`.","error":"pyap.exceptions.CountryDetectionMissing: Detection rules for country \"XX\" not found."},{"fix":"Iterate through the list of addresses or access a specific element by index before calling `as_dict()`. For example: `addresses = pyap.parse(text, country='US')` followed by `for address in addresses: print(address.as_dict())` or `if addresses: print(addresses[0].as_dict())`.","cause":"The `pyap.parse()` function returns a list of `Address` objects, not a single `Address` object. The `as_dict()` method is available on individual `Address` objects, not on the list itself.","error":"AttributeError: 'list' object has no attribute 'as_dict'"}]}