FA-96256 / Postal address normalization / Open access
Rural route and highway token normalizer: single tokens are matched before two-token phrases · case 01
"HIGHWAY CONTRACT 3" becomes "HWY CONTRACT 3".
ROOT CAUSE
The single-token table is consulted first, so HIGHWAY is consumed before the phrase is seen.
THE FAILURE
The single-token table is consulted first, so HIGHWAY is consumed before the phrase is seen.
Unsuccessful approach: Keeping single tokens first but dropping HIGHWAY from that table leaves plain highways unabbreviated.
Case contract
Uppercase, delete periods, split. Two-token phrases RURAL ROUTE / RURAL RTE -> RR and HIGHWAY CONTRACT -> HC are matched before single tokens RR, HIGHWAY/HWY -> HWY, HC, BOX/BX -> BOX. A fused token "RR" + digits splits into RR and the digits. Other tokens pass through; join with spaces.
Why this case matters
Rural delivery lines have no street name; their route and box tokens are the whole delivery address and must normalize identically.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
t = x.upper().replace('.', '').split()
MAP2 = {('RURAL', 'ROUTE'): 'RR', ('HIGHWAY', 'CONTRACT'): 'HC', ('RURAL', 'RTE'): 'RR'}
MAP1 = {'RR': 'RR', 'HIGHWAY': 'HWY', 'HWY': 'HWY', 'HC': 'HC', 'BOX': 'BOX', 'BX': 'BOX'}
out, i = [], 0
while i < len(t):
pair = tuple(t[i:i + 2])
if t[i] in MAP1:
out.append(MAP1[t[i]])
i += 1
elif pair in MAP2:
out.append(MAP2[pair])
i += 2
elif t[i][:2] == 'RR' and t[i][2:].isdigit():
out.extend(['RR', t[i][2:]])
i += 1
else:
out.append(t[i])
i += 1
return ' '.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['spelled rural route', 'Rural Route 2 Box 11', 'RR 2 BOX 11'], ['dotted route and short box', 'R.R. 2 BX 11', 'RR 2 BOX 11'], ['fused two-digit route', 'RR21 BOX 3', 'RR 21 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 2 BOX 11', 'HC 2 BOX 11'], ['plain highway', '11 HIGHWAY 2', '11 HWY 2'], ['abbreviated route word', 'RURAL RTE 2', 'RR 2'], ['street control', '11 FAKE RD', '11 FAKE RD']], [['spelled rural route', 'Rural Route 3 Box 12', 'RR 3 BOX 12'], ['dotted route and short box', 'R.R. 3 BX 12', 'RR 3 BOX 12'], ['fused two-digit route', 'RR32 BOX 3', 'RR 32 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 3 BOX 12', 'HC 3 BOX 12'], ['plain highway', '12 HIGHWAY 3', '12 HWY 3'], ['abbreviated route word', 'RURAL RTE 3', 'RR 3'], ['street control', '12 FAKE RD', '12 FAKE RD']], [['spelled rural route', 'Rural Route 4 Box 13', 'RR 4 BOX 13'], ['dotted route and short box', 'R.R. 4 BX 13', 'RR 4 BOX 13'], ['fused two-digit route', 'RR43 BOX 3', 'RR 43 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 4 BOX 13', 'HC 4 BOX 13'], ['plain highway', '13 HIGHWAY 4', '13 HWY 4'], ['abbreviated route word', 'RURAL RTE 4', 'RR 4'], ['street control', '13 FAKE RD', '13 FAKE RD']], [['spelled rural route', 'Rural Route 5 Box 14', 'RR 5 BOX 14'], ['dotted route and short box', 'R.R. 5 BX 14', 'RR 5 BOX 14'], ['fused two-digit route', 'RR54 BOX 3', 'RR 54 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 5 BOX 14', 'HC 5 BOX 14'], ['plain highway', '14 HIGHWAY 5', '14 HWY 5'], ['abbreviated route word', 'RURAL RTE 5', 'RR 5'], ['street control', '14 FAKE RD', '14 FAKE RD']], [['spelled rural route', 'Rural Route 6 Box 15', 'RR 6 BOX 15'], ['dotted route and short box', 'R.R. 6 BX 15', 'RR 6 BOX 15'], ['fused two-digit route', 'RR65 BOX 3', 'RR 65 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 6 BOX 15', 'HC 6 BOX 15'], ['plain highway', '15 HIGHWAY 6', '15 HWY 6'], ['abbreviated route word', 'RURAL RTE 6', 'RR 6'], ['street control', '15 FAKE RD', '15 FAKE RD']]]
for label, arg, expected in fixtures[N - 1]:
check(label, solve(arg), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| spelled rural route | RR 2 BOX 11 | RR 2 BOX 11 | Passed |
| dotted route and short box | RR 2 BOX 11 | RR 2 BOX 11 | Passed |
| fused two-digit route | RR 21 BOX 3 | RR 21 BOX 3 | Passed |
| highway contract route | HWY CONTRACT 2 BOX 11 | HC 2 BOX 11 | Failed |
| plain highway | 11 HWY 2 | 11 HWY 2 | Passed |
| abbreviated route word | RR 2 | RR 2 | Passed |
| street control | 11 FAKE RD | 11 FAKE RD | Passed |
SHA-256 / 39b23ebfaf8eb546e51eb1065ca4086f2a293907ffbdd4465bb3ed0ddff88ca8
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
t = x.upper().replace('.', '').split()
MAP2 = {('RURAL', 'ROUTE'): 'RR', ('HIGHWAY', 'CONTRACT'): 'HC', ('RURAL', 'RTE'): 'RR'}
MAP1 = {'RR': 'RR', 'HWY': 'HWY', 'HC': 'HC', 'BOX': 'BOX', 'BX': 'BOX'}
out, i = [], 0
while i < len(t):
pair = tuple(t[i:i + 2])
if t[i] in MAP1:
out.append(MAP1[t[i]])
i += 1
elif pair in MAP2:
out.append(MAP2[pair])
i += 2
elif t[i][:2] == 'RR' and t[i][2:].isdigit():
out.extend(['RR', t[i][2:]])
i += 1
else:
out.append(t[i])
i += 1
return ' '.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['spelled rural route', 'Rural Route 2 Box 11', 'RR 2 BOX 11'], ['dotted route and short box', 'R.R. 2 BX 11', 'RR 2 BOX 11'], ['fused two-digit route', 'RR21 BOX 3', 'RR 21 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 2 BOX 11', 'HC 2 BOX 11'], ['plain highway', '11 HIGHWAY 2', '11 HWY 2'], ['abbreviated route word', 'RURAL RTE 2', 'RR 2'], ['street control', '11 FAKE RD', '11 FAKE RD']], [['spelled rural route', 'Rural Route 3 Box 12', 'RR 3 BOX 12'], ['dotted route and short box', 'R.R. 3 BX 12', 'RR 3 BOX 12'], ['fused two-digit route', 'RR32 BOX 3', 'RR 32 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 3 BOX 12', 'HC 3 BOX 12'], ['plain highway', '12 HIGHWAY 3', '12 HWY 3'], ['abbreviated route word', 'RURAL RTE 3', 'RR 3'], ['street control', '12 FAKE RD', '12 FAKE RD']], [['spelled rural route', 'Rural Route 4 Box 13', 'RR 4 BOX 13'], ['dotted route and short box', 'R.R. 4 BX 13', 'RR 4 BOX 13'], ['fused two-digit route', 'RR43 BOX 3', 'RR 43 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 4 BOX 13', 'HC 4 BOX 13'], ['plain highway', '13 HIGHWAY 4', '13 HWY 4'], ['abbreviated route word', 'RURAL RTE 4', 'RR 4'], ['street control', '13 FAKE RD', '13 FAKE RD']], [['spelled rural route', 'Rural Route 5 Box 14', 'RR 5 BOX 14'], ['dotted route and short box', 'R.R. 5 BX 14', 'RR 5 BOX 14'], ['fused two-digit route', 'RR54 BOX 3', 'RR 54 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 5 BOX 14', 'HC 5 BOX 14'], ['plain highway', '14 HIGHWAY 5', '14 HWY 5'], ['abbreviated route word', 'RURAL RTE 5', 'RR 5'], ['street control', '14 FAKE RD', '14 FAKE RD']], [['spelled rural route', 'Rural Route 6 Box 15', 'RR 6 BOX 15'], ['dotted route and short box', 'R.R. 6 BX 15', 'RR 6 BOX 15'], ['fused two-digit route', 'RR65 BOX 3', 'RR 65 BOX 3'], ['highway contract route', 'HIGHWAY CONTRACT 6 BOX 15', 'HC 6 BOX 15'], ['plain highway', '15 HIGHWAY 6', '15 HWY 6'], ['abbreviated route word', 'RURAL RTE 6', 'RR 6'], ['street control', '15 FAKE RD', '15 FAKE RD']]]
for label, arg, expected in fixtures[N - 1]:
check(label, solve(arg), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| spelled rural route | RR 2 BOX 11 | RR 2 BOX 11 | Passed |
| dotted route and short box | RR 2 BOX 11 | RR 2 BOX 11 | Passed |
| fused two-digit route | RR 21 BOX 3 | RR 21 BOX 3 | Passed |
| highway contract route | HC 2 BOX 11 | HC 2 BOX 11 | Passed |
| plain highway | 11 HIGHWAY 2 | 11 HWY 2 | Failed |
| abbreviated route word | RR 2 | RR 2 | Passed |
| street control | 11 FAKE RD | 11 FAKE RD | Passed |
SHA-256 / 5525a658ab276a08b7970e181d0a91d9133069d8926c9f3f7661827f641b8cbc
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic toy contract over synthetic, obviously fictitious addresses. The rules are stipulated for this model only and make no claim of conformance with any postal authority standard. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:52:21.297696+00:00.
Case digest / a54b9113bac0e130fb786294e306a1eb7287afbfed5da0a66a791cae5a48bbd4