-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathADDRESSS_GRAMMAR.txt
67 lines (46 loc) · 1.94 KB
/
ADDRESSS_GRAMMAR.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# first pass at grammar for implementing a more formal
# address parser. Elements in curly braces will presumably
# come from DB lookup tables.
# (how to express beginning of line in BNF?)
# normalize(location text)
<location> ::== (<street> <intersectionsep> <street>) |
(<address>? <addrsep> <place>? <addrsep>
<unit>? <addrsep> <addrstate>? <addrsep>
<zipcode>?);
<address> ::== <house>? <whitespace> <street>;
<street> ::== <predir>? <whitespace> <pretyp>? <whitespace> <prequal>? <whitespace>
<streetname> <whitespace>
<suftype>? <whitespace> <sufdir>? <whitespace> <sufqual>?;
# cope with michigan rural addresses?
<house> :== (<housenumber>|<houserange>) <whitespace>+;
<housenumber> :== 'G'*<digit>+;
<houserange> ::== <housenumber>-<housenumber>;
<predir> ::== {List of predirs};
<pretype> ::== {List of pretypes};
<prequal> ::== {List of prequals};
<streetname> ::== <word>+;
<suftype> ::== {List of suftypes};
<sufdir> ::== {List of sufdirs};
<sufqual> ::== {List of sufquals};
<place> ::== <addrsep> <placename>;
<placename> ::== <word> <wordspace>*;
<unit> ::== <unittype> <whitespace>+ <unitno>;
<unittype> ::== {list of possible unit types};
<unitno> ::== <alphanum>+| "#";
<state> ::== <addrsep> <statename>;
<state> ::== {List of state names};
<zipcode> ::== <zip5><zipsuf>?;
<zip5> ::== <digit><digit><digit><digit><digit>;
<zipsuf> ::== <zipsep>?<zip4>
<zip4> ::== <digit><digit><digit><digit><digit>;
<zipsep> ::== "+" | "-";
<digit> ::== 1/2/3/4/5/6/7/8/9/0
<wordspace> ::== <whitespace>+<word>
<word> ::== [a-z.-]+;
<alphanum> ::== <digit>+|<word>+;
<intersectionsep> ::== <whitespace>+ <and> <whitespace>+;
<and> ::== '&' | 'and';
<addrsep> ::== <addrsep-char>+
<addrsep-char> ::== <whitespace>+| <whitespace>* ',' <whitespace>*;
<whitespace> ::== <whitespace-char>+ ;
<whitespace-char> ::== "[beginning of line]" | " " | "\t" | "\r" | "\n" ;