Parse an address with libpostal
parse_address_libpostalParse free-text addresses into ISO 20022 postal fields (street name, building number, postal code, town, country) using libpostal or regex fallback, with optional country hint.
Instructions
Parse a free-text address into ISO 20022 postal fields.
Uses the optional libpostal statistical parser (the ``postal`` binding,
which requires the system libpostal C library) when it is installed,
and otherwise degrades to this repo's own regex heuristics. Either way
the address is mapped to ``StrtNm``, ``BldgNb``, ``PstCd``, ``TwnNm``
and ``Ctry``. The result's ``parser`` field is ``"libpostal"`` or
``"fallback"`` so callers know which path ran. Runs purely on CPU with
no network or filesystem access, though the libpostal path depends on
an external C library.
Args:
unstructured_address: The free-text address to parse.
country_hint: Country to assume when the text names none.
Returns ``{"parser": ..., "address": {StrtNm, BldgNb, PstCd, TwnNm,
Ctry}}``.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| country_hint | No | An ISO 3166-1 alpha-2 hint (or country name) used when the address text does not name its own country. | |
| unstructured_address | Yes | A single free-text postal address, e.g. '12 Rue de Rivoli, 75001 Paris, France'. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||