This commit is contained in:
Andras Schmelczer 2026-03-12 22:11:00 +00:00
parent 14a3555cf1
commit 7e92bf112e
34 changed files with 1214437 additions and 224 deletions

View file

@ -7,3 +7,16 @@ pub use grid_index::GridIndex;
pub use hash::{generate_priorities, splitmix64_hash};
pub use interned_column::InternedColumn;
pub use llm::{extract_ollama_content, ollama_chat, strip_think_blocks};
/// Normalize a UK postcode: uppercase, strip spaces, insert canonical space before inward code.
/// e.g. "e142dg" → "E14 2DG", "E14 2DG" → "E14 2DG", "EC1A1BB" → "EC1A 1BB"
pub fn normalize_postcode(raw: &str) -> String {
let stripped: String = raw.chars().filter(|c| !c.is_whitespace()).collect();
let upper = stripped.to_uppercase();
if upper.len() >= 5 {
let (outward, inward) = upper.split_at(upper.len() - 3);
format!("{} {}", outward, inward)
} else {
upper
}
}