Documentation ¶
Overview ¶
Package address contains tools for working with and comparing street addresses.
Index ¶
- Constants
- func NonOverlappingComponents(placeA, placeB Address) (uniqueToA, uniqueToB int)
- func NormalizeSuffixes(s string) string
- func NormalizedSharedComponentDistance(placeA, placeB *Address) (distance int)
- func NormalizedSharedComponentDistanceSlice(placeA, placeB Address) (distances []int)
- func NormalizedTotalDistance(placeA, placeB *Address) (distance int)
- func SharedComponentDistance(placeA, placeB *Address) (distance int)
- func SharedComponents(a, b Address) (Address, Address)
- func TotalDistance(placeA, placeB *Address) (distance int)
- type Address
Constants ¶
const ( StreetNumber componentType = "street_number" Route componentType = "route" //street Subpremise componentType = "subpremise" //unit number Locality componentType = "locality" //city AdministrativeAreaLevel1 componentType = "administrative_area_level_1" //state PostalCode componentType = "postal_code" //zip Country componentType = "country" )
Variables ¶
This section is empty.
Functions ¶
func NormalizeSuffixes ¶
NormalizeSuffixes normalizes lowercase address suffixes to the standard format used by the United States Postal Service. i.e, "pkwy": "parkway", see http://www.pb.com/docs/us/pdf/sis/mail-services/usps-suffix-abbreviations.pdf
func NormalizedSharedComponentDistance ¶
NormalizedSharedComponentDistance performs heavy normalization on both addresses, then compares the distance.
func NormalizedTotalDistance ¶
NormalizedTotalDistance Performs heavy normalization on both addresses, then compares the distance.
func SharedComponentDistance ¶
SharedComponentDistance returns the sum of the levenshtein distance of the shared components of the addresses
func SharedComponents ¶
SharedComponents returns copies of a and b, except if a.component == "" || b.component == "", c.component == "" && d.component == ""
func TotalDistance ¶
TotalDistance returns the sum of the levenshtein distance of the components of the addresses.
Types ¶
type Address ¶
type Address struct { Street string `json:"street,omitempty"` Extension string `json:"extension,omitempty"` POBox string `json:"po_box,omitempty"` Locality string `json:"locality,omitempty"` Region string `json:"region,omitempty"` PostalCode string `json:"post_code,omitempty"` Country string `json:"country,omitempty"` }
Address represents a physical location
func FromFactualRecord ¶
FromFactualRecord builds an address from a serialized record from factual
func FromGoogleAddressComponents ¶
func FromGoogleAddressComponents(addressComponents []maps.AddressComponent, whitelist ...componentType) (address Address)
FromGoogleAddressComponents creates an Addresss from a slice of components, using the AddressCompoment.Types to discriminate.
func FromStringSlice ¶
FromStringSlice turns a length-7 string slice into an Address.
func (*Address) NonEmptyComponents ¶
NonEmptyComponents is the number of nonempty components of a; that is, an address with only a steet has 1, street and locality is 2, ...
func (*Address) StringSlice ¶
StringSlice turns an address into a []string
func (*Address) StringSliceFromNonempty ¶
StringSliceFromNonempty returns a stringslice of the non-empty components of a