Indirizzo 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Indirizzo.gemspec +28 -0
- data/LICENSE.txt +165 -0
- data/README.md +56 -0
- data/Rakefile +31 -0
- data/VERSION +1 -0
- data/lib/indirizzo.rb +1 -0
- data/lib/indirizzo/address.rb +286 -0
- data/lib/indirizzo/constants.rb +666 -0
- data/lib/indirizzo/numbers.rb +55 -0
- data/test/test_address.rb +228 -0
- data/test/test_constants.rb +55 -0
- data/test/test_helper.rb +4 -0
- data/test/test_numbers.rb +44 -0
- metadata +102 -0
@@ -0,0 +1,666 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'set'
|
3
|
+
require 'indirizzo/numbers'
|
4
|
+
|
5
|
+
module Indirizzo
|
6
|
+
class Map < Hash
|
7
|
+
# The Map class provides a two-way mapping between postal abbreviations
|
8
|
+
# and their fully written equivalents.
|
9
|
+
#attr_accessor :partial
|
10
|
+
attr_accessor :regexp
|
11
|
+
def self.[] (*items)
|
12
|
+
hash = super(*items)
|
13
|
+
#hash.build_partial
|
14
|
+
hash.build_match
|
15
|
+
hash.keys.each {|k| hash[k.downcase] = hash.fetch(k)}
|
16
|
+
hash.values.each {|v| hash[v.downcase] = v}
|
17
|
+
hash.freeze
|
18
|
+
end
|
19
|
+
# The build_partial method constructs a hash of case-insensitive,
|
20
|
+
# whitespace-delimited prefixes to keys and values in the two-way Map.
|
21
|
+
def build_partial
|
22
|
+
@partial = Set.new()
|
23
|
+
[keys, values].flatten.each {|item|
|
24
|
+
@partial << item.downcase
|
25
|
+
item.downcase.split.each {|token| @partial << token}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
def build_match
|
29
|
+
@regexp = Regexp.new(
|
30
|
+
'\b(' + [keys,values].flatten.join("|") + ')\b',
|
31
|
+
Regexp::IGNORECASE)
|
32
|
+
end
|
33
|
+
# The partial? method returns true if the key is a prefix of some
|
34
|
+
# key in the Map.
|
35
|
+
def partial? (key)
|
36
|
+
@partial.member? key.downcase
|
37
|
+
end
|
38
|
+
def key? (key)
|
39
|
+
super(key.downcase)
|
40
|
+
end
|
41
|
+
def [] (key)
|
42
|
+
super(key.downcase)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# The Directional constant maps compass direction words in English and
|
47
|
+
# Spanish to their 1- or 2- letter abbreviations. See 2008 TIGER/Line
|
48
|
+
# technical documentation Appendix C for more details.
|
49
|
+
Directional = Map[
|
50
|
+
"North" => "N",
|
51
|
+
"South" => "S",
|
52
|
+
"East" => "E",
|
53
|
+
"West" => "W",
|
54
|
+
"Northeast" => "NE",
|
55
|
+
"Northwest" => "NW",
|
56
|
+
"Southeast" => "SE",
|
57
|
+
"Southwest" => "SW",
|
58
|
+
"Norte" => "N",
|
59
|
+
"Sur" => "S",
|
60
|
+
"Este" => "E",
|
61
|
+
"Oeste" => "O",
|
62
|
+
"Noreste" => "NE",
|
63
|
+
"Noroeste" => "NO",
|
64
|
+
"Sudeste" => "SE",
|
65
|
+
"Sudoeste" => "SO"
|
66
|
+
]
|
67
|
+
|
68
|
+
# The Prefix_Qualifier constant maps feature prefix qualifiers to their
|
69
|
+
# abbreviations. See 2008 TIGER/Line technical documentation Appendix D.
|
70
|
+
Prefix_Qualifier = Map[
|
71
|
+
"Alternate" => "Alt",
|
72
|
+
"Business" => "Bus",
|
73
|
+
"Bypass" => "Byp",
|
74
|
+
"Extended" => "Exd",
|
75
|
+
"Historic" => "Hst",
|
76
|
+
"Loop" => "Lp",
|
77
|
+
"Old" => "Old",
|
78
|
+
"Private" => "Pvt",
|
79
|
+
"Public" => "Pub",
|
80
|
+
"Spur" => "Spr",
|
81
|
+
]
|
82
|
+
|
83
|
+
# The Suffix_Qualifier constant maps feature suffix qualifiers to their
|
84
|
+
# abbreviations. See 2008 TIGER/Line technical documentation Appendix D.
|
85
|
+
Suffix_Qualifier = Map[
|
86
|
+
"Access" => "Acc",
|
87
|
+
"Alternate" => "Alt",
|
88
|
+
"Business" => "Bus",
|
89
|
+
"Bypass" => "Byp",
|
90
|
+
"Connector" => "Con",
|
91
|
+
"Extended" => "Exd",
|
92
|
+
"Extension" => "Exn",
|
93
|
+
"Loop" => "Lp",
|
94
|
+
"Private" => "Pvt",
|
95
|
+
"Public" => "Pub",
|
96
|
+
"Scenic" => "Scn",
|
97
|
+
"Spur" => "Spr",
|
98
|
+
"Ramp" => "Rmp",
|
99
|
+
"Underpass" => "Unp",
|
100
|
+
"Overpass" => "Ovp",
|
101
|
+
]
|
102
|
+
|
103
|
+
# The Prefix_Canonical constant maps canonical TIGER/Line street type
|
104
|
+
# prefixes to their abbreviations. This list is the subset of the list from
|
105
|
+
# 2008 TIGER/Line technical documentation Appendix E that was extracted from
|
106
|
+
# a TIGER/Line database import.
|
107
|
+
Prefix_Canonical = {
|
108
|
+
"Arcade" => "Arc",
|
109
|
+
"Autopista" => "Autopista",
|
110
|
+
"Avenida" => "Ave",
|
111
|
+
"Avenue" => "Ave",
|
112
|
+
"Boulevard" => "Blvd",
|
113
|
+
"Bulevar" => "Bulevar",
|
114
|
+
"Bureau of Indian Affairs Highway" => "BIA Hwy",
|
115
|
+
"Bureau of Indian Affairs Road" => "BIA Rd",
|
116
|
+
"Bureau of Indian Affairs Route" => "BIA Rte",
|
117
|
+
"Bureau of Land Management Road" => "BLM Rd",
|
118
|
+
"Bypass" => "Byp",
|
119
|
+
"Calle" => "Cll",
|
120
|
+
"Calleja" => "Calleja",
|
121
|
+
"Callejón" => "Callejón",
|
122
|
+
"Caminito" => "Cmt",
|
123
|
+
"Camino" => "Cam",
|
124
|
+
"Carretera" => "Carr",
|
125
|
+
"Cerrada" => "Cer",
|
126
|
+
"Círculo" => "Cír",
|
127
|
+
"Commons" => "Cmns",
|
128
|
+
"Corte" => "Corte",
|
129
|
+
"County Highway" => "Co Hwy",
|
130
|
+
"County Lane" => "Co Ln",
|
131
|
+
"County Road" => "Co Rd",
|
132
|
+
"County Route" => "Co Rte",
|
133
|
+
"County State Aid Highway" => "Co St Aid Hwy",
|
134
|
+
"County Trunk Highway" => "Co Trunk Hwy",
|
135
|
+
"County Trunk Road" => "Co Trunk Rd",
|
136
|
+
"Court" => "Ct",
|
137
|
+
"Delta Road" => "Delta Rd",
|
138
|
+
"District of Columbia Highway" => "DC Hwy",
|
139
|
+
"Driveway" => "Driveway",
|
140
|
+
"Entrada" => "Ent",
|
141
|
+
"Expreso" => "Expreso",
|
142
|
+
"Expressway" => "Expy",
|
143
|
+
"Farm Road" => "Farm Rd",
|
144
|
+
"Farm-to-Market Road" => "FM",
|
145
|
+
"Fire Control Road" => "Fire Cntrl Rd",
|
146
|
+
"Fire District Road" => "Fire Dist Rd",
|
147
|
+
"Fire Lane" => "Fire Ln",
|
148
|
+
"Fire Road" => "Fire Rd",
|
149
|
+
"Fire Route" => "Fire Rte",
|
150
|
+
"Fire Trail" => "Fire Trl",
|
151
|
+
"Forest Highway" => "Forest Hwy",
|
152
|
+
"Forest Road" => "Forest Rd",
|
153
|
+
"Forest Route" => "Forest Rte",
|
154
|
+
"Forest Service Road" => "FS Rd",
|
155
|
+
"Highway" => "Hwy",
|
156
|
+
"Indian Route" => "Indian Rte",
|
157
|
+
"Indian Service Route" => "Indian Svc Rte",
|
158
|
+
"Interstate Highway" => "I-",
|
159
|
+
"Lane" => "Ln",
|
160
|
+
"Logging Road" => "Logging Rd",
|
161
|
+
"Loop" => "Loop",
|
162
|
+
"National Forest Development Road" => "Nat For Dev Rd",
|
163
|
+
"Navajo Service Route" => "Navajo Svc Rte",
|
164
|
+
"Parish Road" => "Parish Rd",
|
165
|
+
"Pasaje" => "Pasaje",
|
166
|
+
"Paseo" => "Pso",
|
167
|
+
"Passage" => "Psge",
|
168
|
+
"Placita" => "Pla",
|
169
|
+
"Plaza" => "Plz",
|
170
|
+
"Point" => "Pt",
|
171
|
+
"Puente" => "Puente",
|
172
|
+
"Ranch Road" => "Ranch Rd",
|
173
|
+
"Ranch to Market Road" => "RM",
|
174
|
+
"Reservation Highway" => "Resvn Hwy",
|
175
|
+
"Road" => "Rd",
|
176
|
+
"Route" => "Rte",
|
177
|
+
"Row" => "Row",
|
178
|
+
"Rue" => "Rue",
|
179
|
+
"Ruta" => "Ruta",
|
180
|
+
"Sector" => "Sec",
|
181
|
+
"Sendero" => "Sendero",
|
182
|
+
"Service Road" => "Svc Rd",
|
183
|
+
"Skyway" => "Skwy",
|
184
|
+
"Square" => "Sq",
|
185
|
+
"State Forest Service Road" => "St FS Rd",
|
186
|
+
"State Highway" => "State Hwy",
|
187
|
+
"State Loop" => "State Loop",
|
188
|
+
"State Road" => "State Rd",
|
189
|
+
"State Route" => "State Rte",
|
190
|
+
"State Spur" => "State Spur",
|
191
|
+
"State Trunk Highway" => "St Trunk Hwy",
|
192
|
+
"Terrace" => "Ter",
|
193
|
+
"Town Highway" => "Town Hwy",
|
194
|
+
"Town Road" => "Town Rd",
|
195
|
+
"Township Highway" => "Twp Hwy",
|
196
|
+
"Township Road" => "Twp Rd",
|
197
|
+
"Trail" => "Trl",
|
198
|
+
"Tribal Road" => "Tribal Rd",
|
199
|
+
"Tunnel" => "Tunl",
|
200
|
+
"US Forest Service Highway" => "USFS Hwy",
|
201
|
+
"US Forest Service Road" => "USFS Rd",
|
202
|
+
"US Highway" => "US Hwy",
|
203
|
+
"US Route" => "US Rte",
|
204
|
+
"Vereda" => "Ver",
|
205
|
+
"Via" => "Via",
|
206
|
+
"Vista" => "Vis",
|
207
|
+
}
|
208
|
+
|
209
|
+
# The Prefix_Alternate constant maps alternate prefix street types to
|
210
|
+
# their canonical abbreviations. This list was merged in from the USPS
|
211
|
+
# list at http://www.usps.com/ncsc/lookups/abbr_suffix.txt.
|
212
|
+
Prefix_Alternate = {
|
213
|
+
"Av" => "Ave",
|
214
|
+
"Aven" => "Ave",
|
215
|
+
"Avenu" => "Ave",
|
216
|
+
"Avenue" => "Ave",
|
217
|
+
"Avn" => "Ave",
|
218
|
+
"Avnue" => "Ave",
|
219
|
+
"Boul" => "Blvd",
|
220
|
+
"Boulv" => "Blvd",
|
221
|
+
"Bypa" => "Byp",
|
222
|
+
"Bypas" => "Byp",
|
223
|
+
"Byps" => "Byp",
|
224
|
+
"Crt" => "Ct",
|
225
|
+
"Exp" => "Expy",
|
226
|
+
"Expr" => "Expy",
|
227
|
+
"Express" => "Expy",
|
228
|
+
"Expw" => "Expy",
|
229
|
+
"Highwy" => "Hwy",
|
230
|
+
"Hiway" => "Hwy",
|
231
|
+
"Hiwy" => "Hwy",
|
232
|
+
"Hway" => "Hwy",
|
233
|
+
#"La" => "Ln", # causes problems with Spanglish place names
|
234
|
+
"Lanes" => "Ln",
|
235
|
+
"Loops" => "Loop",
|
236
|
+
"Plza" => "Plz",
|
237
|
+
"Sqr" => "Sq",
|
238
|
+
"Sqre" => "Sq",
|
239
|
+
"Squ" => "Sq",
|
240
|
+
"Terr" => "Ter",
|
241
|
+
"Tr" => "Trl",
|
242
|
+
"Trails" => "Trl",
|
243
|
+
"Trls" => "Trl",
|
244
|
+
"Tunel" => "Tunl",
|
245
|
+
"Tunls" => "Tunl",
|
246
|
+
"Tunnels" => "Tunl",
|
247
|
+
"Tunnl" => "Tunl",
|
248
|
+
"Vdct" => "Via",
|
249
|
+
"Viadct" => "Via",
|
250
|
+
"Viaduct" => "Via",
|
251
|
+
"Vist" => "Vis",
|
252
|
+
"Vst" => "Vis",
|
253
|
+
"Vsta" => "Vis"
|
254
|
+
}
|
255
|
+
|
256
|
+
# The Prefix_Type constant merges the canonical prefix type abbreviations
|
257
|
+
# with their USPS accepted alternates.
|
258
|
+
Prefix_Type = Map[ Prefix_Canonical.merge(Prefix_Alternate) ]
|
259
|
+
|
260
|
+
# The Suffix_Canonical constant maps canonical TIGER/Line street type
|
261
|
+
# suffixes to their abbreviations. This list is the subset of the list from
|
262
|
+
# 2008 TIGER/Line technical documentation Appendix E that was extracted from
|
263
|
+
# a TIGER/Line database import.
|
264
|
+
Suffix_Canonical = {
|
265
|
+
"Alley" => "Aly",
|
266
|
+
"Arcade" => "Arc",
|
267
|
+
"Avenida" => "Ave",
|
268
|
+
"Avenue" => "Ave",
|
269
|
+
"Beltway" => "Beltway",
|
270
|
+
"Boulevard" => "Blvd",
|
271
|
+
"Bridge" => "Brg",
|
272
|
+
"Bypass" => "Byp",
|
273
|
+
"Causeway" => "Cswy",
|
274
|
+
"Circle" => "Cir",
|
275
|
+
"Common" => "Cmn",
|
276
|
+
"Commons" => "Cmns",
|
277
|
+
"Corners" => "Cors",
|
278
|
+
"Court" => "Ct",
|
279
|
+
"Courts" => "Cts",
|
280
|
+
"Crescent" => "Cres",
|
281
|
+
"Crest" => "Crst",
|
282
|
+
"Crossing" => "Xing",
|
283
|
+
"Cutoff" => "Cutoff",
|
284
|
+
"Drive" => "Dr",
|
285
|
+
"Driveway" => "Driveway",
|
286
|
+
"Esplanade" => "Esplanade",
|
287
|
+
"Estates" => "Ests",
|
288
|
+
"Expressway" => "Expy",
|
289
|
+
"Forest Highway" => "Forest Hwy",
|
290
|
+
"Fork" => "Frk",
|
291
|
+
"Four-Wheel Drive Trail" => "4WD Trl",
|
292
|
+
"Freeway" => "Fwy",
|
293
|
+
"Grade" => "Grade",
|
294
|
+
"Heights" => "Hts",
|
295
|
+
"Highway" => "Hwy",
|
296
|
+
"Jeep Trail" => "Jeep Trl",
|
297
|
+
"Landing" => "Lndg",
|
298
|
+
"Lane" => "Ln",
|
299
|
+
"Logging Road" => "Logging Rd",
|
300
|
+
"Loop" => "Loop",
|
301
|
+
"Motorway" => "Mtwy",
|
302
|
+
"Oval" => "Oval",
|
303
|
+
"Overpass" => "Opas",
|
304
|
+
"Parkway" => "Pkwy",
|
305
|
+
"Pass" => "Pass",
|
306
|
+
"Passage" => "Psge",
|
307
|
+
"Path" => "Path",
|
308
|
+
"Pike" => "Pike",
|
309
|
+
"Place" => "Pl",
|
310
|
+
"Plaza" => "Plz",
|
311
|
+
"Point" => "Pt",
|
312
|
+
"Pointe" => "Pointe",
|
313
|
+
"Promenade" => "Promenade",
|
314
|
+
"Railroad" => "RR",
|
315
|
+
"Railway" => "Rlwy",
|
316
|
+
"Ramp" => "Ramp",
|
317
|
+
"River" => "Riv",
|
318
|
+
"Road" => "Rd",
|
319
|
+
"Roadway" => "Roadway",
|
320
|
+
"Route" => "Rte",
|
321
|
+
"Row" => "Row",
|
322
|
+
"Rue" => "Rue",
|
323
|
+
"Service Road" => "Svc Rd",
|
324
|
+
"Skyway" => "Skwy",
|
325
|
+
"Spur" => "Spur",
|
326
|
+
"Square" => "Sq",
|
327
|
+
"Stravenue" => "Stra",
|
328
|
+
"Street" => "St",
|
329
|
+
"Strip" => "Strip",
|
330
|
+
"Terrace" => "Ter",
|
331
|
+
"Thoroughfare" => "Thoroughfare",
|
332
|
+
"Tollway" => "Tollway",
|
333
|
+
"Trace" => "Trce",
|
334
|
+
"Trafficway" => "Trfy",
|
335
|
+
"Trail" => "Trl",
|
336
|
+
"Trolley" => "Trolley",
|
337
|
+
"Truck Trail" => "Truck Trl",
|
338
|
+
"Tunnel" => "Tunl",
|
339
|
+
"Turnpike" => "Tpke",
|
340
|
+
"Viaduct" => "Viaduct",
|
341
|
+
"View" => "Vw",
|
342
|
+
"Vista" => "Vis",
|
343
|
+
"Walk" => "Walk",
|
344
|
+
"Walkway" => "Walkway",
|
345
|
+
"Way" => "Way",
|
346
|
+
}
|
347
|
+
|
348
|
+
# The Suffix_Alternate constant maps alternate suffix street types to
|
349
|
+
# their canonical abbreviations. This list was merged in from the USPS
|
350
|
+
# list at http://www.usps.com/ncsc/lookups/abbr_suffix.txt.
|
351
|
+
Suffix_Alternate = {
|
352
|
+
"Allee" => "Aly",
|
353
|
+
"Ally" => "Aly",
|
354
|
+
"Av" => "Ave",
|
355
|
+
"Aven" => "Ave",
|
356
|
+
"Avenu" => "Ave",
|
357
|
+
"Avenue" => "Ave",
|
358
|
+
"Avn" => "Ave",
|
359
|
+
"Avnue" => "Ave",
|
360
|
+
"Boul" => "Blvd",
|
361
|
+
"Boulv" => "Blvd",
|
362
|
+
"Brdge" => "Brg",
|
363
|
+
"Bypa" => "Byp",
|
364
|
+
"Bypas" => "Byp",
|
365
|
+
"Byps" => "Byp",
|
366
|
+
"Causway" => "Cswy",
|
367
|
+
"Circ" => "Cir",
|
368
|
+
"Circl" => "Cir",
|
369
|
+
"Crcl" => "Cir",
|
370
|
+
"Crcle" => "Cir",
|
371
|
+
"Crecent" => "Cres",
|
372
|
+
"Cresent" => "Cres",
|
373
|
+
"Crscnt" => "Cres",
|
374
|
+
"Crsent" => "Cres",
|
375
|
+
"Crsnt" => "Cres",
|
376
|
+
"Crssing" => "Xing",
|
377
|
+
"Crssng" => "Xing",
|
378
|
+
"Crt" => "Ct",
|
379
|
+
"Driv" => "Dr",
|
380
|
+
"Drv" => "Dr",
|
381
|
+
"Exp" => "Expy",
|
382
|
+
"Expr" => "Expy",
|
383
|
+
"Express" => "Expy",
|
384
|
+
"Expw" => "Expy",
|
385
|
+
"Freewy" => "Fwy",
|
386
|
+
"Frway" => "Fwy",
|
387
|
+
"Frwy" => "Fwy",
|
388
|
+
"Height" => "Hts",
|
389
|
+
"Hgts" => "Hts",
|
390
|
+
"Highwy" => "Hwy",
|
391
|
+
"Hiway" => "Hwy",
|
392
|
+
"Hiwy" => "Hwy",
|
393
|
+
"Ht" => "Hts",
|
394
|
+
"Hway" => "Hwy",
|
395
|
+
"La" => "Ln",
|
396
|
+
"Lanes" => "Ln",
|
397
|
+
"Lndng" => "Lndg",
|
398
|
+
"Loops" => "Loop",
|
399
|
+
"Ovl" => "Oval",
|
400
|
+
"Parkways" => "Pkwy",
|
401
|
+
"Parkwy" => "Pkwy",
|
402
|
+
"Paths" => "Path",
|
403
|
+
"Pikes" => "Pike",
|
404
|
+
"Pkway" => "Pkwy",
|
405
|
+
"Pkwys" => "Pkwy",
|
406
|
+
"Pky" => "Pkwy",
|
407
|
+
"Plza" => "Plz",
|
408
|
+
"Rivr" => "Riv",
|
409
|
+
"Rvr" => "Riv",
|
410
|
+
"Spurs" => "Spur",
|
411
|
+
"Sqr" => "Sq",
|
412
|
+
"Sqre" => "Sq",
|
413
|
+
"Squ" => "Sq",
|
414
|
+
"Str" => "St",
|
415
|
+
"Strav" => "Stra",
|
416
|
+
"Strave" => "Stra",
|
417
|
+
"Straven" => "Stra",
|
418
|
+
"Stravn" => "Stra",
|
419
|
+
"Strt" => "St",
|
420
|
+
"Strvn" => "Stra",
|
421
|
+
"Strvnue" => "Stra",
|
422
|
+
"Terr" => "Ter",
|
423
|
+
"Tpk" => "Tpke",
|
424
|
+
"Tr" => "Trl",
|
425
|
+
"Traces" => "Trce",
|
426
|
+
"Trails" => "Trl",
|
427
|
+
"Trls" => "Trl",
|
428
|
+
"Trnpk" => "Tpke",
|
429
|
+
"Trpk" => "Tpke",
|
430
|
+
"Tunel" => "Tunl",
|
431
|
+
"Tunls" => "Tunl",
|
432
|
+
"Tunnels" => "Tunl",
|
433
|
+
"Tunnl" => "Tunl",
|
434
|
+
"Turnpk" => "Tpke",
|
435
|
+
"Vist" => "Vis",
|
436
|
+
"Vst" => "Vis",
|
437
|
+
"Vsta" => "Vis",
|
438
|
+
"Walks" => "Walk",
|
439
|
+
"Wy" => "Way",
|
440
|
+
}
|
441
|
+
|
442
|
+
# The Suffix_Type constant merges the canonical suffix type abbreviations
|
443
|
+
# with their USPS accepted alternates.
|
444
|
+
Suffix_Type = Map[ Suffix_Canonical.merge(Suffix_Alternate) ]
|
445
|
+
|
446
|
+
# The Unit_Type constant lists acceptable USPS unit type abbreviations
|
447
|
+
# from http://www.usps.com/ncsc/lookups/abbr_sud.txt.
|
448
|
+
Unit_Type = Map[
|
449
|
+
"Apartment" => "Apt",
|
450
|
+
"Basement" => "Bsmt",
|
451
|
+
"Building" => "Bldg",
|
452
|
+
"Department"=> "Dept",
|
453
|
+
"Floor" => "Fl",
|
454
|
+
"Front" => "Frnt",
|
455
|
+
"Hangar" => "Hngr",
|
456
|
+
"Lobby" => "Lbby",
|
457
|
+
"Lot" => "Lot",
|
458
|
+
"Lower" => "Lowr",
|
459
|
+
"Office" => "Ofc",
|
460
|
+
"Penthouse" => "Ph",
|
461
|
+
"Pier" => "Pier",
|
462
|
+
"Rear" => "Rear",
|
463
|
+
"Room" => "Rm",
|
464
|
+
"Side" => "Side",
|
465
|
+
"Slip" => "Slip",
|
466
|
+
"Space" => "Spc",
|
467
|
+
"Stop" => "Stop",
|
468
|
+
"Suite" => "Ste",
|
469
|
+
"Trailer" => "Trlr",
|
470
|
+
"Unit" => "Unit",
|
471
|
+
"Upper" => "Uppr",
|
472
|
+
]
|
473
|
+
|
474
|
+
Std_Abbr = Map[
|
475
|
+
[Directional, Prefix_Qualifier, Suffix_Qualifier,
|
476
|
+
Prefix_Type, Suffix_Type].inject({}) {|x,y|x.merge y}
|
477
|
+
]
|
478
|
+
|
479
|
+
# The Name_Abbr constant maps common toponym abbreviations to their
|
480
|
+
# full word equivalents. This list was constructed partly by hand, and
|
481
|
+
# partly by matching USPS alternate abbreviations with feature names
|
482
|
+
# found in the TIGER/Line dataset.
|
483
|
+
Name_Abbr = Map[
|
484
|
+
"Av" => "Avenue",
|
485
|
+
"Ave" => "Avenue",
|
486
|
+
"Blvd" => "Boulevard",
|
487
|
+
"Bot" => "Bottom",
|
488
|
+
"Boul" => "Boulevard",
|
489
|
+
"Boulv" => "Boulevard",
|
490
|
+
"Br" => "Branch",
|
491
|
+
"Brg" => "Bridge",
|
492
|
+
"Canyn" => "Canyon",
|
493
|
+
"Cen" => "Center",
|
494
|
+
"Cent" => "Center",
|
495
|
+
"Cir" => "Circle",
|
496
|
+
"Circ" => "Circle",
|
497
|
+
"Ck" => "Creek",
|
498
|
+
"Cnter" => "Center",
|
499
|
+
"Cntr" => "Center",
|
500
|
+
"Cnyn" => "Canyon",
|
501
|
+
"Cor" => "Corner",
|
502
|
+
"Cors" => "Corners",
|
503
|
+
"Cp" => "Camp",
|
504
|
+
"Cr" => "Creek",
|
505
|
+
"Crcl" => "Circle",
|
506
|
+
"Crcle" => "Circle",
|
507
|
+
"Cres" => "Crescent",
|
508
|
+
"Crscnt" => "Crescent",
|
509
|
+
"Ct" => "Court",
|
510
|
+
"Ctr" => "Center",
|
511
|
+
"Cts" => "Courts",
|
512
|
+
"Cyn" => "Canyon",
|
513
|
+
"Div" => "Divide",
|
514
|
+
"Dr" => "Drive",
|
515
|
+
"Dv" => "Divide",
|
516
|
+
"Est" => "Estate",
|
517
|
+
"Ests" => "Estates",
|
518
|
+
"Ext" => "Extension",
|
519
|
+
"Extn" => "Extension",
|
520
|
+
"Extnsn" => "Extension",
|
521
|
+
"Forests" => "Forest",
|
522
|
+
"Forg" => "Forge",
|
523
|
+
"Frg" => "Forge",
|
524
|
+
"Ft" => "Fort",
|
525
|
+
"Gatewy" => "Gateway",
|
526
|
+
"Gdn" => "Garden",
|
527
|
+
"Gdns" => "Gardens",
|
528
|
+
"Gtwy" => "Gateway",
|
529
|
+
"Harb" => "Harbor",
|
530
|
+
"Hbr" => "Harbor",
|
531
|
+
"Height" => "Heights",
|
532
|
+
"Hgts" => "Heights",
|
533
|
+
"Highwy" => "Highway",
|
534
|
+
"Hiway" => "Highway",
|
535
|
+
"Hiwy" => "Highway",
|
536
|
+
"Holws" => "Hollow",
|
537
|
+
"Ht" => "Heights",
|
538
|
+
"Hway" => "Highway",
|
539
|
+
"Hwy" => "Highway",
|
540
|
+
"Is" => "Island",
|
541
|
+
"Iss" => "Islands",
|
542
|
+
"Jct" => "Junction",
|
543
|
+
"Jction" => "Junction",
|
544
|
+
"Jctn" => "Junction",
|
545
|
+
"Junctn" => "Junction",
|
546
|
+
"Juncton" => "Junction",
|
547
|
+
"Ldg" => "Lodge",
|
548
|
+
"Lgt" => "Light",
|
549
|
+
"Lndg" => "Landing",
|
550
|
+
"Lodg" => "Lodge",
|
551
|
+
"Loops" => "Loop",
|
552
|
+
"Mt" => "Mount",
|
553
|
+
"Mtin" => "Mountain",
|
554
|
+
"Mtn" => "Mountain",
|
555
|
+
"Orch" => "Orchard",
|
556
|
+
"Parkwy" => "Parkway",
|
557
|
+
"Pk" => "Park",
|
558
|
+
"Pkway" => "Parkway",
|
559
|
+
"Pkwy" => "Parkway",
|
560
|
+
"Pky" => "Parkway",
|
561
|
+
"Pl" => "Place",
|
562
|
+
"Pnes" => "Pines",
|
563
|
+
"Pr" => "Prairie",
|
564
|
+
"Prr" => "Prairie",
|
565
|
+
"Pt" => "Point",
|
566
|
+
"Pts" => "Points",
|
567
|
+
"Rdg" => "Ridge",
|
568
|
+
"Riv" => "River",
|
569
|
+
"Rnchs" => "Ranch",
|
570
|
+
"Spg" => "Spring",
|
571
|
+
"Spgs" => "Springs",
|
572
|
+
"Spng" => "Spring",
|
573
|
+
"Spngs" => "Springs",
|
574
|
+
"Sq" => "Square",
|
575
|
+
"Squ" => "Square",
|
576
|
+
# "St" => "Saint",
|
577
|
+
"Sta" => "Station",
|
578
|
+
"Statn" => "Station",
|
579
|
+
"Ste" => "Sainte",
|
580
|
+
"Stn" => "Station",
|
581
|
+
"Str" => "Street",
|
582
|
+
"Ter" => "Terrace",
|
583
|
+
"Terr" => "Terrace",
|
584
|
+
"Tpk" => "Turnpike",
|
585
|
+
"Tpke" => "Turnpike",
|
586
|
+
"Tr" => "Trail",
|
587
|
+
"Trls" => "Trail",
|
588
|
+
"Trpk" => "Turnpike",
|
589
|
+
"Tunls" => "Tunnel",
|
590
|
+
"Un" => "Union",
|
591
|
+
"Vill" => "Village",
|
592
|
+
"Villag" => "Village",
|
593
|
+
"Villg" => "Village",
|
594
|
+
"Vis" => "Vista",
|
595
|
+
"Vlg" => "Village",
|
596
|
+
"Vlgs" => "Villages",
|
597
|
+
"Wls" => "Wells",
|
598
|
+
"Wy" => "Way",
|
599
|
+
"Xing" => "Crossing",
|
600
|
+
]
|
601
|
+
|
602
|
+
# The State constant maps US state and territory names to their 2-letter
|
603
|
+
# USPS abbreviations.
|
604
|
+
State = Map[
|
605
|
+
"Alabama" => "AL",
|
606
|
+
"Alaska" => "AK",
|
607
|
+
"American Samoa" => "AS",
|
608
|
+
"Arizona" => "AZ",
|
609
|
+
"Arkansas" => "AR",
|
610
|
+
"California" => "CA",
|
611
|
+
"Colorado" => "CO",
|
612
|
+
"Connecticut" => "CT",
|
613
|
+
"Delaware" => "DE",
|
614
|
+
"District of Columbia" => "DC",
|
615
|
+
"Federated States of Micronesia" => "FM",
|
616
|
+
"Florida" => "FL",
|
617
|
+
"Georgia" => "GA",
|
618
|
+
"Guam" => "GU",
|
619
|
+
"Hawaii" => "HI",
|
620
|
+
"Idaho" => "ID",
|
621
|
+
"Illinois" => "IL",
|
622
|
+
"Indiana" => "IN",
|
623
|
+
"Iowa" => "IA",
|
624
|
+
"Kansas" => "KS",
|
625
|
+
"Kentucky" => "KY",
|
626
|
+
"Louisiana" => "LA",
|
627
|
+
"Maine" => "ME",
|
628
|
+
"Marshall Islands" => "MH",
|
629
|
+
"Maryland" => "MD",
|
630
|
+
"Massachusetts" => "MA",
|
631
|
+
"Michigan" => "MI",
|
632
|
+
"Minnesota" => "MN",
|
633
|
+
"Mississippi" => "MS",
|
634
|
+
"Missouri" => "MO",
|
635
|
+
"Montana" => "MT",
|
636
|
+
"Nebraska" => "NE",
|
637
|
+
"Nevada" => "NV",
|
638
|
+
"New Hampshire" => "NH",
|
639
|
+
"New Jersey" => "NJ",
|
640
|
+
"New Mexico" => "NM",
|
641
|
+
"New York" => "NY",
|
642
|
+
"North Carolina" => "NC",
|
643
|
+
"North Dakota" => "ND",
|
644
|
+
"Northern Mariana Islands" => "MP",
|
645
|
+
"Ohio" => "OH",
|
646
|
+
"Oklahoma" => "OK",
|
647
|
+
"Oregon" => "OR",
|
648
|
+
"Palau" => "PW",
|
649
|
+
"Pennsylvania" => "PA",
|
650
|
+
"Puerto Rico" => "PR",
|
651
|
+
"Rhode Island" => "RI",
|
652
|
+
"South Carolina" => "SC",
|
653
|
+
"South Dakota" => "SD",
|
654
|
+
"Tennessee" => "TN",
|
655
|
+
"Texas" => "TX",
|
656
|
+
"Utah" => "UT",
|
657
|
+
"Vermont" => "VT",
|
658
|
+
"Virgin Islands" => "VI",
|
659
|
+
"Virginia" => "VA",
|
660
|
+
"Washington" => "WA",
|
661
|
+
"West Virginia" => "WV",
|
662
|
+
"Wisconsin" => "WI",
|
663
|
+
"Wyoming" => "WY"
|
664
|
+
]
|
665
|
+
|
666
|
+
end
|