FAILURE MAP
← Case archive

FA-96276 / Postal address normalization / Open access

Rural route and highway token normalizer: the short box token is not normalized · case 01

"BX 11" stays "BX 11".

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The single-token table lacks BX.

VERIFIED REPAIR

Map both BOX and BX to BOX.

Unsuccessful approach: Mapping box tokens to "PO BOX" confuses rural boxes with post office boxes.

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'}
    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 fixtureActualExpectedOutcome
spelled rural routeRR 2 BOX 11RR 2 BOX 11Passed
dotted route and short boxRR 2 BX 11RR 2 BOX 11Failed
fused two-digit routeRR 21 BOX 3RR 21 BOX 3Passed
highway contract routeHC 2 BOX 11HC 2 BOX 11Passed
plain highway11 HWY 211 HWY 2Passed
abbreviated route wordRR 2RR 2Passed
street control11 FAKE RD11 FAKE RDPassed

SHA-256 / 52e45bba9cd52ac4fcf3186a06037ea2efacd1cda0e64234e10049d24421f09c

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': 'PO BOX', 'BX': 'PO 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 fixtureActualExpectedOutcome
spelled rural routeRR 2 PO BOX 11RR 2 BOX 11Failed
dotted route and short boxRR 2 PO BOX 11RR 2 BOX 11Failed
fused two-digit routeRR 21 PO BOX 3RR 21 BOX 3Failed
highway contract routeHC 2 PO BOX 11HC 2 BOX 11Failed
plain highway11 HWY 211 HWY 2Passed
abbreviated route wordRR 2RR 2Passed
street control11 FAKE RD11 FAKE RDPassed

SHA-256 / ecc565d37a1d14ca313b7291c7b4c946c40109e42a926c552fdaddc0bad430d7

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 fixtureActualExpectedOutcome
spelled rural routeRR 2 BOX 11RR 2 BOX 11Passed
dotted route and short boxRR 2 BOX 11RR 2 BOX 11Passed
fused two-digit routeRR 21 BOX 3RR 21 BOX 3Passed
highway contract routeHC 2 BOX 11HC 2 BOX 11Passed
plain highway11 HWY 211 HWY 2Passed
abbreviated route wordRR 2RR 2Passed
street control11 FAKE RD11 FAKE RDPassed

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.297696+00:00.

Case digest / d15b3d09dc515f157f4743a7e3710083c3d4a002ab0ddea245c2f940fd143d35