manukall / postie

A Libpostal NIF for Erlang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Postie

A Libpostal NIF for Erlang & Elixir

Postman Pat

FAQ

What's Postie for?

Postie is a NIF for Erlang & Elixir that allows you to use libpostal's natural language processing algorithm to normalise and parse physical addresses. This is useful for matching or filtering addresses in your system.

What's a NIF?

NIFs (Native Implemented Functions) are one way of integrating external code into Erlang or Elixir. Postie uses the libpostal C bindings to provide an interface you can use in your projects just as if it was a regular Elixir library.

NIFs have some pretty hefty downsides though - if something goes wrong with them they can take down your entire erlang VM (!), and they can negatively effect the performance of your VM's scheduler. You can find out more about that in the bitwise project.

Installation

If available in Hex, the package can be installed as:

  1. Add postie to your list of dependencies in mix.exs:

    def deps do [{:postie, "~> 0.0.1"}] end

  2. Ensure postie is started before your application:

    def application do [applications: [:postie]] end

Usage

To parse an an address:

iex(1)> Postie.parse_address("The Book Club 100-106 Leonard St Shoreditch London EC2A 4RH, United Kingdom")
[house: "the book club", house_number: "100-106", road: "leonard st",
suburb: "shoreditch", city: "london", postcode: "ec2a 4rh",
country: "united kingdom"]

To expand an address:

iex(3)> Postie.expand_address("Quatre vingt douze R. de l'Église")
["92 rue de l'eglise", "92 r de l'eglise", "92 rue de l eglise",
"92 rue de 50 eglise", "92 r de l eglise", "92 r de 50 eglise"]

About

A Libpostal NIF for Erlang

License:MIT License


Languages

Language:Elixir 40.3%Language:CMake 30.6%Language:C 29.1%