feat: relax MT regex and add country-level fallback (#14)#20
Merged
Conversation
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
added a commit
that referenced
this pull request
Mar 12, 2026
feat: relax MT regex and add country-level fallback (#14)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MST1000now pass regex extraction and get exact TERCET matches (confidence 1.0) instead of falling to approximate matching.1043that previously failed now get a valid result.Closes #14
Test plan
ruff check app/passespython -c "from app.main import app"imports OKMST 1000), without space (MST1000), and with dash (MST-1000) all return exact matches1043) return approximate result with MT0/MT00/MT001 instead of 404