FA-96261 / Postal address normalization / Open access
Rural route and highway token normalizer: dotted route abbreviations are not recognized · case 01
"R.R. 2" is left as typed.
ROOT CAUSE
Periods are not removed before tokenizing.
VERIFIED REPAIR
Delete periods so "R.R." becomes "RR".
Unsuccessful approach: Turning periods into spaces yields "R R", which is not a route token.
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().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 pair in MAP2:
out.append(MAP2[pair])
i += 2
elif t[i] in MAP1:
out.append(MAP1[t[i]])
i += 1
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 | R.R. 2 BOX 11 | RR 2 BOX 11 | Failed |
| 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 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 / f61956c3dfeb43a2f9653a8311b74ad77a9cdf92eaecfaff33592c36818deb9a
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', 'HIGHWAY': 'HWY', 'HWY': 'HWY', 'HC': 'HC', 'BOX': 'BOX', 'BX': 'BOX'}
out, i = [], 0
while i < len(t):
pair = tuple(t[i:i + 2])
if pair in MAP2:
out.append(MAP2[pair])
i += 2
elif t[i] in MAP1:
out.append(MAP1[t[i]])
i += 1
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 | R R 2 BOX 11 | RR 2 BOX 11 | Failed |
| 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 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 / 953193514344964414c9c39279988c106642eba1932e698707e230fa673a3a45
3 / The verified repair
Exit 0"""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 pair in MAP2:
out.append(MAP2[pair])
i += 2
elif t[i] in MAP1:
out.append(MAP1[t[i]])
i += 1
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 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 / f84e33cbba9a34ac789b8915927383ad810eefb84e7061b2d3a66b2a269e1ad9
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.225777+00:00.
Case digest / 3737c124f336405f72ffe84f8c6d65076a6c128f84f0a07c2c45634560693df5