Skip to content

Commit bfbd6da

Browse files
committed
* Bundle libpostal_data program, executable via Loader.load() for convenience (issue #939)
1 parent ab34a7f commit bfbd6da

15 files changed

+108
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Bundle `libpostal_data` program, executable via `Loader.load()` for convenience ([issue #939](https://github.com/bytedeco/javacpp-presets/issues/939))
23
* Enable all stable target architectures in the presets for LLVM ([pull #937](https://github.com/bytedeco/javacpp-presets/pull/937))
34
* Virtualize `QObject` and its subclasses from Qt to allow customization ([issue bytedeco/javacpp#419](https://github.com/bytedeco/javacpp/issues/419))
45
* Bundle programs from Clang and LLVM, executable via `Loader.load()` for convenience ([issue #833](https://github.com/bytedeco/javacpp-presets/issues/833))

libpostal/README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ This directory contains the JavaCPP Presets module for:
1010
libpostal is a C library for parsing/normalizing street addresses around the world using statistical NLP and open data.
1111
The goal of this project is to understand location-based strings in every language, everywhere.
1212

13+
1314
Data Files
1415
----------
15-
1616
libpostal needs to download a few gigabytes of data from S3. The basic files are on-disk representations of the data structures necessary to perform expansion.
1717
For address parsing, since model training takes a few days, the libpostal team publishes the fully trained model to S3 and will update it automatically as new addresses get added to OSM, OpenAddresses, etc.
1818
Same goes for the language classifier model. Data files are automatically downloaded when you run the build with enabled data download.
1919
To check for and download any new data files, you can either run ```make```, or run:
2020

21-
```libpostal_data download all $YOUR_DATA_DIR```
21+
```java
22+
String libpostal_data = Loader.load(org.bytedeco.libpostal.libpostal_data.class);
23+
ProcessBuilder pb = new ProcessBuilder("bash", libpostal_data, "download", "all", "/path/to/libpostal/data/");
24+
pb.inheritIO().start().waitFor();
25+
```
26+
27+
Replace `"/path/to/libpostal/data/"` with the path where the training data should be stored.
2228

23-
Replace $YOUR_DATA_DIR with the path where the training data should be stored.
2429

2530
Documentation
2631
-------------
@@ -36,7 +41,7 @@ Here is a simple example of the libpostal parser and normalization functionality
3641
We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries.
3742
To run this sample code, after creating the `pom.xml` and `Example.java` source files below, simply execute on the command line:
3843
```bash
39-
$ mvn compile exec:java -Dexec.args="/PATH_TO_LIBPOSTAL_TRAINING_DATA_DIRECTORY"
44+
$ mvn compile exec:java
4045
```
4146

4247
### The `pom.xml` build file
@@ -45,15 +50,15 @@ To run this sample code, after creating the `pom.xml` and `Example.java` source
4550
<modelVersion>4.0.0</modelVersion>
4651
<groupId>org.bytedeco.libpostal</groupId>
4752
<artifactId>example</artifactId>
48-
<version>1.5.3</version>
53+
<version>1.5.4-SNAPSHOT</version>
4954
<properties>
5055
<exec.mainClass>Example</exec.mainClass>
5156
</properties>
5257
<dependencies>
5358
<dependency>
5459
<groupId>org.bytedeco</groupId>
5560
<artifactId>libpostal-platform</artifactId>
56-
<version>1.1-alpha-1.5.3</version>
61+
<version>1.1-alpha-1.5.4-SNAPSHOT</version>
5762
</dependency>
5863
</dependencies>
5964
<build>
@@ -70,7 +75,11 @@ import static org.bytedeco.libpostal.global.postal.*;
7075

7176
public class Example {
7277
public static void main(String[] args) throws Exception {
73-
String dataDir = args.length >= 1 ? new String(args[0]) : "/PATH_TO_LIBPOSTAL_TRAINING_DATA_DIRECTORY";
78+
String dataDir = args.length >= 1 ? new String(args[0]) : "data/";
79+
String libpostal_data = Loader.load(org.bytedeco.libpostal.libpostal_data.class);
80+
ProcessBuilder pb = new ProcessBuilder("bash", libpostal_data, "download", "all", dataDir);
81+
pb.inheritIO().start().waitFor();
82+
7483
boolean setup1 = libpostal_setup_datadir(dataDir);
7584
boolean setup2 = libpostal_setup_parser_datadir(dataDir);
7685
boolean setup3 = libpostal_setup_language_classifier_datadir(dataDir);

libpostal/samples/Example.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
public class Example {
66
public static void main(String[] args) throws Exception {
7-
String dataDir = args.length >= 1 ? new String(args[0]) : "/PATH_TO_LIBPOSTAL_TRAINING_DATA_DIRECTORY";
7+
String dataDir = args.length >= 1 ? new String(args[0]) : "data/";
8+
String libpostal_data = Loader.load(org.bytedeco.libpostal.libpostal_data.class);
9+
ProcessBuilder pb = new ProcessBuilder("bash", libpostal_data, "download", "all", dataDir);
10+
pb.inheritIO().start().waitFor();
11+
812
boolean setup1 = libpostal_setup_datadir(dataDir);
913
boolean setup2 = libpostal_setup_parser_datadir(dataDir);
1014
boolean setup3 = libpostal_setup_language_classifier_datadir(dataDir);

libpostal/samples/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.bytedeco.libpostal</groupId>
44
<artifactId>example</artifactId>
5-
<version>1.5.3</version>
5+
<version>1.5.4-SNAPSHOT</version>
66
<properties>
77
<exec.mainClass>Example</exec.mainClass>
88
</properties>
99
<dependencies>
1010
<dependency>
1111
<groupId>org.bytedeco</groupId>
1212
<artifactId>libpostal-platform</artifactId>
13-
<version>1.1-alpha-1.5.3</version>
13+
<version>1.1-alpha-1.5.4-SNAPSHOT</version>
1414
</dependency>
1515
</dependencies>
1616
<build>

libpostal/src/gen/java/org/bytedeco/libpostal/global/postal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.3: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.4-SNAPSHOT: DO NOT EDIT THIS FILE
22

33
package org.bytedeco.libpostal.global;
44

libpostal/src/gen/java/org/bytedeco/libpostal/libpostal_address_parser_options_t.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.3: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.4-SNAPSHOT: DO NOT EDIT THIS FILE
22

33
package org.bytedeco.libpostal;
44

@@ -25,6 +25,9 @@ public class libpostal_address_parser_options_t extends Pointer {
2525
@Override public libpostal_address_parser_options_t position(long position) {
2626
return (libpostal_address_parser_options_t)super.position(position);
2727
}
28+
@Override public libpostal_address_parser_options_t getPointer(long i) {
29+
return new libpostal_address_parser_options_t(this).position(position + i);
30+
}
2831

2932
public native @Cast("char*") BytePointer language(); public native libpostal_address_parser_options_t language(BytePointer setter);
3033
public native @Cast("char*") BytePointer country(); public native libpostal_address_parser_options_t country(BytePointer setter);

libpostal/src/gen/java/org/bytedeco/libpostal/libpostal_address_parser_response_t.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.3: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.4-SNAPSHOT: DO NOT EDIT THIS FILE
22

33
package org.bytedeco.libpostal;
44

@@ -29,6 +29,9 @@ public class libpostal_address_parser_response_t extends Pointer {
2929
@Override public libpostal_address_parser_response_t position(long position) {
3030
return (libpostal_address_parser_response_t)super.position(position);
3131
}
32+
@Override public libpostal_address_parser_response_t getPointer(long i) {
33+
return new libpostal_address_parser_response_t(this).position(position + i);
34+
}
3235

3336
public native @Cast("size_t") long num_components(); public native libpostal_address_parser_response_t num_components(long setter);
3437
public native @Cast("char*") BytePointer components(int i); public native libpostal_address_parser_response_t components(int i, BytePointer setter);

libpostal/src/gen/java/org/bytedeco/libpostal/libpostal_duplicate_options_t.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.3: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.4-SNAPSHOT: DO NOT EDIT THIS FILE
22

33
package org.bytedeco.libpostal;
44

@@ -25,6 +25,9 @@ public class libpostal_duplicate_options_t extends Pointer {
2525
@Override public libpostal_duplicate_options_t position(long position) {
2626
return (libpostal_duplicate_options_t)super.position(position);
2727
}
28+
@Override public libpostal_duplicate_options_t getPointer(long i) {
29+
return new libpostal_duplicate_options_t(this).position(position + i);
30+
}
2831

2932
public native @Cast("size_t") long num_languages(); public native libpostal_duplicate_options_t num_languages(long setter);
3033
public native @Cast("char*") BytePointer languages(int i); public native libpostal_duplicate_options_t languages(int i, BytePointer setter);

libpostal/src/gen/java/org/bytedeco/libpostal/libpostal_fuzzy_duplicate_options_t.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.3: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.4-SNAPSHOT: DO NOT EDIT THIS FILE
22

33
package org.bytedeco.libpostal;
44

@@ -27,6 +27,9 @@ public class libpostal_fuzzy_duplicate_options_t extends Pointer {
2727
@Override public libpostal_fuzzy_duplicate_options_t position(long position) {
2828
return (libpostal_fuzzy_duplicate_options_t)super.position(position);
2929
}
30+
@Override public libpostal_fuzzy_duplicate_options_t getPointer(long i) {
31+
return new libpostal_fuzzy_duplicate_options_t(this).position(position + i);
32+
}
3033

3134
public native @Cast("size_t") long num_languages(); public native libpostal_fuzzy_duplicate_options_t num_languages(long setter);
3235
public native @Cast("char*") BytePointer languages(int i); public native libpostal_fuzzy_duplicate_options_t languages(int i, BytePointer setter);

libpostal/src/gen/java/org/bytedeco/libpostal/libpostal_fuzzy_duplicate_status_t.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.3: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.4-SNAPSHOT: DO NOT EDIT THIS FILE
22

33
package org.bytedeco.libpostal;
44

@@ -25,6 +25,9 @@ public class libpostal_fuzzy_duplicate_status_t extends Pointer {
2525
@Override public libpostal_fuzzy_duplicate_status_t position(long position) {
2626
return (libpostal_fuzzy_duplicate_status_t)super.position(position);
2727
}
28+
@Override public libpostal_fuzzy_duplicate_status_t getPointer(long i) {
29+
return new libpostal_fuzzy_duplicate_status_t(this).position(position + i);
30+
}
2831

2932
public native @Cast("libpostal_duplicate_status_t") int status(); public native libpostal_fuzzy_duplicate_status_t status(int setter);
3033
public native double similarity(); public native libpostal_fuzzy_duplicate_status_t similarity(double setter);

0 commit comments

Comments
 (0)