Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pramsey/pgsql-postal
PostgreSQL binding for libpostal
https://github.com/pramsey/pgsql-postal
Last synced: 16 days ago
JSON representation
PostgreSQL binding for libpostal
- Host: GitHub
- URL: https://github.com/pramsey/pgsql-postal
- Owner: pramsey
- License: mit
- Created: 2016-03-12T18:01:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-27T18:55:37.000Z (almost 4 years ago)
- Last Synced: 2024-08-01T00:37:55.865Z (3 months ago)
- Language: C
- Size: 7.81 KB
- Stars: 135
- Watchers: 15
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PostgreSQL Postal Address Normalizer
## Motivation
[Libpostal](https://github.com/openvenues/libpostal) is a C library for parsing/normalizing street addresses around the world. Having that functionality directly in PostgreSQL could potentially be useful.
This extension is for that.
## Usage Notes
* PostgreSQL 9.4 and higher is required because of the JSONB support. Could reduce that by using ordinary JSON as a return type instead.
* [libpostal](https://github.com/openvenues/libpostal) takes quite a lot of memory when intialized, and has a noticeable start-up time. When you first run `postal_normalize` or `postal_parse` there will be a delay while the library data first loads.
* Backends with `libpostal` active will be quite large in terms of memory usage (about 1Gb on my computer) so you probably want to take care about spawning too many of them at once.## Examples
=# SELECT unnest(postal_normalize('412 first ave, victoria, bc'));
unnest
------------------------------------------
412 1st avenue victoria british columbia
412 1st avenue victoria bc
(2 rows)=# SELECT postal_parse('412 first ave, victoria, bc');
postal_parse
---------------------------------------------------------------------------------
{"city": "victoria", "road": "first ave", "state": "bc", "house_number": "412"}
(1 row)## Functions
* `postal_normalize(address TEXT)` returns `TEXT[]`
* `postal_parse(address TEXT)` returns `JSONB`## Installation
### UNIX
If you have PostgreSQL devel packages and CURL devel packages installed, you should have `pg_config` on your path. Confirm by running `which pg_config`.
Edit the paths to `POSTAL_INCLUDE` and `POSTAL_LIBS` in the `Makefile` to refer to your `libpostal` install location, and then run:
make
make installThen in your database `CREATE EXTENSION postal`.
### Windows
Sorry, no story here yet.
## To Do
- Perhaps allow normalization options other than the defaults.