Skip to content

Commit

Permalink
Merge pull request #405 from Inist-CNRS/chore/update-libpostal
Browse files Browse the repository at this point in the history
Update libpostal
  • Loading branch information
parmentf authored Apr 10, 2024
2 parents 661f5eb + 353564c commit 7383190
Show file tree
Hide file tree
Showing 15 changed files with 1,594 additions and 124 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/install-libpostal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

## Script base of the libpostal github action
## https://github.com/openvenues/node-postal/blob/master/.github/workflows/push.yml

# Install required dependencies to build libpostal
sudo apt-get update
sudo apt-get install build-essential curl autoconf automake libtool pkg-config

# Create working directory
sudo mkdir -p /code /data /deps
sudo chown "$USER":"$USER" /code /data /deps

# Install lib postal
cd /code || exit
git clone https://github.com/openvenues/libpostal
cd libpostal || exit
git reset --hard 8f2066b ## Reset to a fixed commit https://github.com/openvenues/libpostal/commit/8f2066b1d30f4290adf59cacc429980f139b8545
./bootstrap.sh
./configure --datadir=/data --prefix=/deps --bindir=/deps || cat config.log
make -j4
make install
16 changes: 16 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,31 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install libpostal
run: bash ${GITHUB_WORKSPACE}/.github/workflows/install-libpostal.sh
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
env:
CXXFLAGS: '-I/deps/include'
LDFLAGS: '-L/deps/lib'
run: yarn run ci:install

- name: Rebuild node-postal (Mainly use to NodeJS 20)
env:
CXXFLAGS: '-I/deps/include'
LDFLAGS: '-L/deps/lib'
run: |
cd node_modules/node-postal
yarn run install
- name: Testing all packages
env:
LD_LIBRARY_PATH: '/deps/lib'
run: yarn run ci:test

- name: Coveralls Parallel
Expand Down
212 changes: 198 additions & 14 deletions docs/plugin-libpostal.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,220 @@ npm install @ezs/libpostal

### expandAddress

Takes a string containing an address to return an object.
This will contain a standardized version of the address.
Try to normalize given addresss.

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Essaye de normaliser les adresses données.

#### Example / Exemple

##### Script / Scénario

```ini
; Import libpostal plugin required to use "expandAddress"
; Importation du plugin libpostal nécessaire pour utiliser "expandAddress"
[use]
plugin = libpostal

; Using "expandAddress"
; Utilisation de "expandAddress"
[expandAddress]
```

##### Input / Entrée

```json
[
"Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238"
]
```

##### Output / Sortie

```json
[
{
"id": "Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238",
"value": [
"barboncino 781 franklin avenue crown heights brooklyn ny 11238",
"barboncino 781 franklin avenue crown heights brooklyn new york 11238"
]
}
]
```

#### Parameters

- `input` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**

Returns **({id: [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>} | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{id: [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>}> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**

### expandAddressWith

Takes a field of object containing an address to return the same object except for the field containing the address.
This will contain a standardized version of the address.
Try to normalize given addresss.

Essaye de normaliser les adresses données.

#### Example / Exemple

##### Script / Scénario

```ini
; Import libpostal plugin required to use "expandAddressWith"
; Importation du plugin libpostal nécessaire pour utiliser "expandAddressWith"
[use]
plugin = libpostal

; Using "expandAddressWith"
; Utilisation de "expandAddressWith"
[expandAddress]
; path = value
```

##### Input / Entrée

```json
[
{
"value": "Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238"
}
]
```

##### Output / Sortie

```json
[
{
"value": {
"id": "Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238",
"value": [
"barboncino 781 franklin avenue crown heights brooklyn ny 11238",
"barboncino 781 franklin avenue crown heights brooklyn new york 11238"
]
}
}
]
```

#### Parameters

- `path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** path to the chosen field
- `input` **({path: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>} | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{path: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>}> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**
- `path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** <ul><li>path of the element to expand</li></ul>
<ul><li>chemin de l'élément à etandre</li></ul> (optional, default `value`)

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Returns **({path: {id: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>}} | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;{path: {id: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>}}> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**

### parseAddress

Takes a string containing an address to return an object.
This will contain the different fields present in the address.
Try to parse given addresss.

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Essaye de faire l'analyse grammaticale des adresses données.

#### Example / Exemple

##### Script / Scénario

```ini
; Import libpostal plugin required to use "parseAddress"
; Importation du plugin libpostal nécessaire pour utiliser "parseAddress"
[use]
plugin = libpostal

; Using "parseAddress"
; Utilisation de "parseAddress"
[parseAddress]
```

##### Input / Entrée

```json
[
"Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238"
]
```

##### Output / Sortie

```json
[
{
"id": "Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238",
"value": {
"house": "barboncino",
"house_number": "781",
"road": "franklin ave",
"suburb": "crown heights",
"city_district": "brooklyn",
"state": "ny",
"postcode": "11238"
}
}
]
```

#### Parameters

- `input` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**

Returns **({id: [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)} | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;{id: [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)}> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**

### parseAddressWith

Takes a field of object containing an address to return the same object except for the field containing the address.
This will contain the different fields found in the address.
Try to parse given addresss.

Essaye de faire l'analyse grammaticale des adresses données.

#### Example / Exemple

##### Script / Scénario

```ini
; Import libpostal plugin required to use "parseAddressWith"
; Importation du plugin libpostal nécessaire pour utiliser "parseAddressWith"
[use]
plugin = libpostal

; Using "parseAddressWith"
; Utilisation de "parseAddressWith"
[expandAddress]
; path = value
```

##### Input / Entrée

```json
[
{
"value": "Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238"
}
]
```

##### Output / Sortie

```json
[
{
"value": {
"id": "Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238",
"value": {
"house": "barboncino",
"house_number": "781",
"road": "franklin ave",
"suburb": "crown heights",
"city_district": "brooklyn",
"state": "ny",
"postcode": "11238"
}
}
}
]
```

#### Parameters

- `path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** path to the chosen field
- `input` **({path: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>} | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;{path: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>}> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**
- `path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** <ul><li>path of the element to parse</li></ul>
<ul><li>chemin de l'élément à analyser</li></ul> (optional, default `value`)

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Returns **({path: {id: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)}} | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;{path: {id: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), value: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)}}> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**
Loading

0 comments on commit 7383190

Please sign in to comment.