Normalize Thai Address
thai_address_normalizeParse free-text Thai addresses into province, district, subdistrict, and postal code with official codes and bilingual names.
Instructions
Parse free-text Thai addresses (Thai or English) into the official administrative hierarchy: province (จังหวัด) → district (อำเภอ/เขต) → subdistrict (ตำบล/แขวง) → postal code, with bilingual names and official codes.
Handles common written forms: abbreviations (ต./อ./จ., กทม.), Bangkok's แขวง/เขต terminology, missing components, and postcode-only inputs. Matching is dictionary-based against the complete official geography (77 provinces, 928 districts, 7,436 subdistricts).
Args:
address (string): free-text address, 2-500 chars
Returns structured JSON: { "province": { "code": number, "nameTh": string, "nameEn": string } | null, "district": { ... } | null, "subdistrict": { ... } | null, "postalCode": number | null, "confidence": "high" | "medium" | "low" | "ambiguous" | "none", "streetHint": string | null, // residual text after removing administrative parts (house no., road, soi) "warnings": string[], // e.g. postcode/subdistrict mismatch "candidates": [...] // present when confidence = "ambiguous"; add district/postcode and retry }
Examples:
Use when: filling a shipping form from a customer's pasted address
Use when: validating that district/province/postcode in a record are consistent
Use when: deduplicating customer records with differently-written addresses
Don't use when: you need geocoding to lat/long (not provided)
Error handling: confidence "none" means nothing matched — the text may not be a Thai address.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Free-text Thai address in Thai or English, e.g. '400/22 ถ.พหลโยธิน แขวงสามเสนใน เขตพญาไท กทม 10400'. Partial addresses work — more components give higher confidence. |