File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed
Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ without the need for the libpostal library to be included as a dependency in the
1212docker run -p 8080 gosom/address-parser-go-rest:v1.0.0
1313```
1414
15+ This will take some time to load
16+
1517then try a sample request
1618
1719```
Original file line number Diff line number Diff line change 11package libpostal
22
33import (
4+ "strings"
5+
46 "github.com/gosom/kit/logging"
57 postal "github.com/openvenues/gopostal/parser"
68 "golang.org/x/text/cases"
@@ -30,6 +32,7 @@ func (o *libPostalParser) Parse(input addressparser.AddressParserInput) (address
3032 tag = r
3133 }
3234 }
35+ houseNumberFound := false
3336 for i := range components {
3437 if input .TitleCase {
3538 components [i ].Value = cases .Title (tag , cases .NoLower ).String (components [i ].Value )
@@ -42,7 +45,10 @@ func (o *libPostalParser) Parse(input addressparser.AddressParserInput) (address
4245 case "near" :
4346 address .Near = components [i ].Value
4447 case "house_number" :
45- address .HouseNumber = components [i ].Value
48+ if ! houseNumberFound {
49+ address .HouseNumber = components [i ].Value
50+ houseNumberFound = true
51+ }
4652 case "road" :
4753 address .Road = components [i ].Value
4854 case "unit" :
@@ -79,6 +85,7 @@ func (o *libPostalParser) Parse(input addressparser.AddressParserInput) (address
7985 o .log .Warn ("Unknown component" , "component" , components [i ].Label )
8086 }
8187 }
88+ address .HouseNumber = strings .TrimSpace (address .HouseNumber )
8289 return address , nil
8390}
8491
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
33import (
44 "context"
55 "embed"
6+ "fmt"
67 "os"
78
89 "github.com/gosom/kit/logging"
@@ -69,6 +70,7 @@ func run(ctx context.Context) error {
6970 Host : addr ,
7071 Router : router ,
7172 }
73+ log .Info (fmt .Sprintf ("Starting server at %s" , addr ))
7274 webSvc := web .NewHttpServer (webCfg )
7375
7476 return webSvc .ListenAndServe (ctx )
You can’t perform that action at this time.
0 commit comments