You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-7Lines changed: 21 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ Every response includes:
109
109
|`nuts{1,2,3}_name`| Human-readable region name (Latin script), or `null` if unavailable |
110
110
|`nuts{1,2,3}_confidence`| Confidence score (0.0–1.0) for each NUTS level |
111
111
112
-
See [Three-tier lookup](#three-tier-lookup) below for details on match types and confidence values.
112
+
See [Five-tier lookup](#five-tier-lookup) below for details on match types and confidence values.
113
113
114
114
The service accepts postal codes with or without country prefixes. For example, all of the following resolve to the same result for Austria: `1010`, `A-1010`, `AT-1010`, `A1010`.
@@ -312,9 +312,9 @@ All settings are overridable via environment variables prefixed with `PC2NUTS_`:
312
312
|`PC2NUTS_ACCESS_LOG_MAX_MB`|`10`| Maximum size of each access log file in MB before rotation. |
313
313
|`PC2NUTS_ACCESS_LOG_BACKUP_COUNT`|`5`| Number of rotated access log files to keep (e.g. 5 x 10 MB = 50 MB max disk usage). |
314
314
315
-
## Three-tier lookup
315
+
## Five-tier lookup
316
316
317
-
The service resolves postal codes using a three-tier fall-through strategy. Each tier adds coverage for codes not found by the tier above, and every result includes a `match_type` and per-level confidence scores so consumers can decide how much to trust the result.
317
+
The service resolves postal codes using a five-tier fall-through strategy. Each tier adds coverage for codes not found by the tier above, and every result includes a `match_type` and per-level confidence scores so consumers can decide how much to trust the result.
318
318
319
319
### Tier 1: Exact match (`match_type: "exact"`)
320
320
@@ -356,11 +356,25 @@ If neither an exact match nor a pre-computed estimate exists, the service perfor
356
356
-`prefix_ratio` = matched prefix length / full postal code length
357
357
- Caps: 0.90 (NUTS1), 0.85 (NUTS2), 0.80 (NUTS3)
358
358
359
-
5. If confidence at NUTS1 level is below 0.1, the result is discarded entirely (returns 404).
359
+
5. If confidence at NUTS1 level is below 0.1, the result is discarded entirely and falls through to the next tier.
For countries where all postal codes map to the same NUTS1 and NUTS2 region but NUTS3 has a dominant winner, the service returns an approximate result using the country-wide distribution. This catches codes that fail prefix matching (e.g. digit-only MT codes like `1043` where TERCET keys are alphabetic).
364
+
365
+
- NUTS1/NUTS2 confidence: **1.0** (unanimous across all postal codes).
366
+
- NUTS3 confidence: agreement ratio capped at **0.80**.
367
+
- Currently applies to MT (MT0/MT00/MT001 at ~77% of postal codes).
368
+
369
+
### Tier 5: Single-NUTS3 country (`match_type: "estimated"`)
370
+
371
+
For countries that have only a single NUTS3 region (e.g. LI, CY, LU), any postal code in that country is mapped to the sole NUTS3 code.
372
+
373
+
- Confidence: **1.0** at all NUTS levels.
360
374
361
375
### No match (404)
362
376
363
-
If all three tiers fail, the service returns a 404 with a format hint for the expected postal code pattern.
377
+
If all five tiers fail, the service returns a 404 with a format hint for the expected postal code pattern.
0 commit comments