NIF interface to the libpostal address parsing library.
This module provides NIF bindings for parsing unstructured address strings into labeled components using libpostal's machine-learning models. The NIF is always compiled and loaded as a required dependency.
Requires the libpostal C library to be installed on the system.
On macOS: brew install libpostal.
Summary
Functions
Returns whether the NIF backend is available.
Parses an address string into labeled components.
Functions
@spec available?() :: boolean()
Returns whether the NIF backend is available.
Returns
trueif the NIF shared library was loaded successfully.falseif the NIF is not compiled or libpostal is missing.
Examples
iex> is_boolean(Localize.Address.Nif.available?())
true
Parses an address string into labeled components.
Arguments
address_stringis the unstructured address string to parse.languageis an optional language hint (ISO 639-1 code) or empty string for automatic detection.
Returns
{:ok, components}wherecomponentsis a list of{label, value}binary tuples.{:error, reason}if parsing fails.