├── .gitignore ├── README.md └── Formula └── libpostal.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libpostal's homebrew repo 2 | 3 | [libpostal](https://github.com/openvenues/libpostal) is a powerful tool to normalize address using NLP around the world. 4 | 5 | ## What is this? 6 | 7 | I use macOS and I need a convenient way to use the lib so I built a repo ~~meanwhile a stable version is released~~. 8 | 9 | ## Why didn't you submit a Formula to Homebrew? 10 | 11 | ~~Because they don't allow alpha quality software.~~ Soon! 12 | 13 | ## How can I use it? 14 | 15 | ``` 16 | brew tap robsalasco/libpostal 17 | brew install libpostal 18 | ``` 19 | ## Using posteR with the lib 20 | 21 | ``` 22 | devtools::install_github("ironholds/poster") 23 | 24 | library(poster) 25 | normalise_addr("Quatre-vignt-douze Ave des Champs-Élysées") 26 | -------------------------------------------------------------------------------- /Formula/libpostal.rb: -------------------------------------------------------------------------------- 1 | class Libpostal < Formula 2 | desc "C library for parsing/normalizing street addresses around the world using NLP and open geo data" 3 | homepage "https://github.com/openvenues/libpostal" 4 | url "https://github.com/openvenues/libpostal/archive/refs/tags/v1.1.tar.gz" 5 | sha256 "8cc473a05126895f183f2578ca234428d8b58ab6fadf550deaacd3bd0ae46032" 6 | head "https://github.com/openvenues/libpostal.git" 7 | 8 | depends_on "autoconf" => :build 9 | depends_on "libtool" => :build 10 | depends_on "automake" => :build 11 | depends_on "pkg-config" => :build 12 | 13 | def install 14 | system "./bootstrap.sh" 15 | 16 | if !Hardware::CPU.arm? 17 | system "./configure", "--disable-debug", 18 | "--disable-dependency-tracking", 19 | "--disable-silent-rules", 20 | "--prefix=#{prefix}", 21 | "--datadir=#{share}/libpostal-data" 22 | else 23 | system "./configure", "--disable-debug", 24 | "--disable-dependency-tracking", 25 | "--disable-silent-rules", 26 | "--disable-sse2", 27 | "--prefix=#{prefix}", 28 | "--datadir=#{share}/libpostal-data" 29 | end 30 | 31 | system "make", "install" 32 | end 33 | 34 | test do 35 | (testpath/"test.c").write <<~EOS 36 | #include 37 | #include 38 | #include 39 | 40 | int main(int argc, char **argv) { 41 | // Setup (only called once at the beginning of your program) 42 | if (!libpostal_setup() || !libpostal_setup_parser()) { 43 | exit(EXIT_FAILURE); 44 | } 45 | 46 | libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options(); 47 | libpostal_address_parser_response_t *parsed = libpostal_parse_address("781 Franklin Ave Crown Heights Brooklyn NYC NY 11216 USA", options); 48 | 49 | for (size_t i = 0; i < parsed->num_components; i++) { 50 | printf("%s: %s\\n", parsed->labels[i], parsed->components[i]); 51 | } 52 | 53 | // Free parse result 54 | libpostal_address_parser_response_destroy(parsed); 55 | 56 | // Teardown (only called once at the end of your program) 57 | libpostal_teardown(); 58 | libpostal_teardown_parser(); 59 | } 60 | EOS 61 | system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", 62 | "-lpostal", "-o", "test" 63 | system "./test" 64 | end 65 | end 66 | --------------------------------------------------------------------------------