Skip to content

feat: relax MT regex and add country-level fallback (#14)#20

Merged
bk86a merged 1 commit intomainfrom
feature/14-mt-regex-country-fallback
Feb 23, 2026
Merged

feat: relax MT regex and add country-level fallback (#14)#20
bk86a merged 1 commit intomainfrom
feature/14-mt-regex-country-fallback

Conversation

@bk86a
Copy link
Owner

@bk86a bk86a commented Feb 23, 2026

Summary

  • MT regex relaxation: separator between alpha prefix and digits is now optional (space, dash, or nothing). Codes like MST1000 now pass regex extraction and get exact TERCET matches (confidence 1.0) instead of falling to approximate matching.
  • Country-level majority-vote fallback (new Tier 4): for countries where all postal codes map to the same NUTS1/NUTS2 but NUTS3 has a dominant winner, returns an approximate result instead of 404. Naturally captures MT (MT0/MT00/MT001 at ~77%). Digit-only codes like 1043 that previously failed now get a valid result.
  • Version bump to 0.12.0.

Closes #14

Test plan

  • ruff check app/ passes
  • python -c "from app.main import app" imports OK
  • MT codes with space (MST 1000), without space (MST1000), and with dash (MST-1000) all return exact matches
  • Digit-only MT codes (1043) return approximate result with MT0/MT00/MT001 instead of 404
  • Existing countries unaffected (no regressions in other lookups)

Make the separator between alpha prefix and digits optional in the MT
postal code regex (space, dash, or nothing all accepted). Codes like
MST1000 now get exact TERCET matches instead of falling to approximate.

Add a new Tier 4 country-level fallback for countries where all postal
codes share the same NUTS1/NUTS2 but NUTS3 has a dominant winner.
Digit-only MT codes that previously returned 404 now resolve to
MT0/MT00/MT001 with appropriate confidence scores.
@bk86a bk86a merged commit 31c1be8 into main Feb 23, 2026
@bk86a bk86a deleted the feature/14-mt-regex-country-fallback branch February 23, 2026 19:21
bk86a added a commit that referenced this pull request Mar 12, 2026
feat: relax MT regex and add country-level fallback (#14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MT: relax regex and add country-level fallback

1 participant