Skip to content

united-drivers/go-normadresse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-normadresse

CircleCI GoDoc Go Report Card License GitHub release

🇫🇷 French Postal Addresses Normalizer (Golang port of etalab/normadresse), following the AFNOR NF Z10-011 specifications.

Usage

Install with go get github.com/united-drivers/go-normadresse

import "github.com/united-drivers/go-normadresse"

fmt.Println(strings.ToUpper(normadresse.Normalize("BOULEVARD DU MARECHAL JEAN MARIE DE LATTRE DE TASSIGNY")))
// Output: BD MAL J M DE LATTRE DE TASSIGNY

More usage on GoDoc, or in the test file.

Under the hood

This library applies rules (sorted with a priority), from the normadresse.csv file, and returns the result as soon as the modified string fits below a max length

Example:

normadresse example

Disclaimer

The original version written in Python uses more efficient rule priorities (than ours), which often results in better outputs

Example:

  • Input: SQUARE DES SOEURS DE SAINT VINCENT DE PAUL
  • Python: SQ SOEURS DE ST VINCENT DE PAUL (easy to read)
  • Golang: SQ DES SOEURS DE SAINT V DE P (correct, but harder to read)

But it gives the exactly same result for others:

  • BOULEVARD DU MARECHAL JEAN MARIE DE LATTRE DE TASSIGNY -> BD MAL J M DE LATTRE DE TASSIGNY
  • RUE DES FRERES MARC ET JEAN MARIE GAMON -> RUE DES FRERES M ET J M GAMON
  • AVENUE GEORGES ET CLAUDE CAUSTIER -> AV GEORGES ET CLAUDE CAUSTIER
  • AVENUE DE LA DIVISION DU GENERAL LECLERC -> AV DE LA DIVISION DU GAL LECLERC
  • RUE EMMANUEL D ASTIER DE LA VIGERIE -> RUE E D ASTIER DE LA VIGERIE
  • ...

License

Apache 2.0