Skip to content

Commit 4ebb393

Browse files
committed
update README.md with new install and functionality instructions
1 parent a1518b9 commit 4ebb393

1 file changed

Lines changed: 67 additions & 24 deletions

File tree

README.md

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
jpostal
22
-------
3-
4-
[![Build Status](https://travis-ci.org/openvenues/jpostal.svg?branch=master)](https://travis-ci.org/openvenues/jpostal)
5-
6-
These are the Java/JNI bindings to [libpostal](https://github.com/openvenues/libpostal), a fast, multilingual NLP library (written in C) for parsing/normalizing physical addresses around the world.
3+
These are the Java/JNI bindings to [libpostal](https://github.com/openvenues/libpostal), a fast, multilingual NLP
4+
library (written in C) for parsing/normalizing physical addresses around the world.
75

86
Usage
97
-----
@@ -15,7 +13,7 @@ import com.mapzen.jpostal.AddressExpander;
1513

1614
// Singleton, libpostal setup is done in the constructor
1715
AddressExpander e = AddressExpander.getInstance();
18-
String[] expansions = e.expandAddress("Quatre vingt douze Ave des Champs-Élysées");
16+
String[] expansions = e.expandAddress("Quatre vingt douze Ave des Champs-Élysées");
1917
```
2018

2119
To parse addresses into components:
@@ -25,11 +23,16 @@ import com.mapzen.jpostal.AddressParser;
2523

2624
// Singleton, parser setup is done in the constructor
2725
AddressParser p = AddressParser.getInstance();
28-
ParsedComponent[] components = p.parseAddress("The Book Club 100-106 Leonard St, Shoreditch, London, Greater London, EC2A 4RH, United Kingdom");
26+
ParsedComponent[] components = p.parseAddress("The Book Club 100-106 Leonard St, Shoreditch, London, Greater London, EC2A 4RH, United Kingdom");
27+
28+
for(
29+
ParsedComponent c :components){
30+
System.out.
31+
32+
printf("%s: %s\n",c.getLabel(),c.
2933

30-
for (ParsedComponent c : components) {
31-
System.out.printf("%s: %s\n", c.getLabel(), c.getValue());
32-
}
34+
getValue());
35+
}
3336
```
3437

3538
To use a libpostal installation with a datadir known at setup-time:
@@ -43,22 +46,60 @@ AddressExpander e = AddressExpander.getInstanceDataDir("/some/path");
4346
AddressParser p = AddressParser.getInstanceDataDir("/some/path");
4447
```
4548

46-
Building libpostal
47-
------------------
49+
To configure the library to download the model data automatically when not present:
50+
51+
```java
52+
53+
import com.mapzen.jpostal.AddressParser;
54+
import com.mapzen.jpostal.AddressExpander;
55+
import com.mapzen.jpostal.Config;
56+
57+
Config config = Config.builder()
58+
.downloadDataIfNeeded(true)
59+
.senzing(true) // Set to true if you want to use Senzing model files
60+
.dataDir("/some/path")
61+
.build();
62+
63+
AddressExpander e = AddressExpander.getInstanceConfig(config);
64+
AddressParser p = AddressParser.getInstanceConfig(config);
65+
```
66+
67+
Installation from Maven Central
68+
-------------------------------
69+
TODO: Publish to Maven Central. For now you can download the jar
70+
from [github](https://github.com/wherobots/jpostal/actions/runs/16152059927/artifacts/3489422226).
4871

49-
Before building the Java bindings, you must install the libpostal C library. Make sure you have the following prerequisites:
72+
TODO: add maven link
73+
74+
We are publishing this version of jpostal to Maven Central. It contains the native code (libjpostal and libpostal). You
75+
can use it in your Java projects with just a Maven dependency. We support:
76+
77+
* ARM and Intel architectures
78+
* Linux and Mac OSX
79+
80+
81+
## Build from Source
82+
If you want to builde from source or have a specific version of libpostal, you can build the JNI bindings.
83+
### Building libpostal
84+
85+
86+
Before building the Java bindings, you must install the libpostal C library. Make sure you have the following
87+
prerequisites:
5088

5189
**On Ubuntu/Debian**
90+
5291
```
5392
sudo apt-get install curl autoconf automake libtool pkg-config
5493
```
5594

5695
**On CentOS/RHEL**
96+
5797
```
5898
sudo yum install curl autoconf automake libtool pkgconfig
5999
```
60100

61101
**On Mac OSX**
102+
62103
```
63104
brew install curl autoconf automake libtool pkg-config
64105
```
@@ -81,33 +122,35 @@ sudo ldconfig
81122
Note: libpostal >= v0.3.3 is required to use this binding.
82123

83124

84-
Building jpostal
85-
----------------
86-
125+
### Building jpostal
87126
Only one command is needed:
88127

89128
```
90129
./gradlew assemble
91130
```
92131

93-
This will leverage gradle's NativeLibrarySpec support to build for the JNI/C portion of the library and installs the resulting shared libraries in the expected location for java.library.path
132+
This will leverage gradle's NativeLibrarySpec support to build for the JNI/C portion of the library and installs the
133+
resulting shared libraries in the expected location for java.library.path
134+
135+
### Usage in a Java project
94136

95-
Usage in a Java project
96-
-----------------------
97137

98-
The JNI portion of jpostal builds shared object files (.so on Linux, .jniLib on Mac) that need to be on java.library.path.
99-
After running ```gradle assemble``` the .so/.jniLib files can be found under ```./libs/jpostal/shared``` in the build dir. For running the tests, we set java.library.path explicitly [here](https://github.com/Qualytics/jpostal/blob/master/build.gradle#L63).
138+
The JNI portion of jpostal builds shared object files (.so on Linux, .jniLib on Mac) that need to be on
139+
java.library.path.
140+
After running ```gradle assemble``` the .so/.jniLib files can be found under ```./libs/jpostal/shared``` in the build
141+
dir. For running the tests, we set java.library.path
142+
explicitly [here](https://github.com/Qualytics/jpostal/blob/master/build.gradle#L63).
100143

101144

102145
Compatibility
103146
-------------
104147

105-
- Building jpostal is known to work on Linux and Mac OSX (including Mac silicon).
106-
- Requires JDK 16 or later. Make sure JAVA_HOME points to JDK 16+.
148+
- Building jpostal is known to work on Linux and Mac OSX (including Mac silicon).
149+
- Requires JDK 16 or later. Make sure JAVA_HOME points to JDK 16+.
107150

151+
## Development
108152

109-
Tests
110-
-----
153+
### Tests
111154

112155
To run the tests:
113156

0 commit comments

Comments
 (0)