From d0aa596ae7fef13a1c023af9bf67a2d5ac6ebd73 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 1 Jul 2026 13:06:52 +0000 Subject: [PATCH] =?UTF-8?q?Deterministically=20guard=20structured=20biomas?= =?UTF-8?q?s=20and=20immersion=20water-heating=20descriptions=20?= =?UTF-8?q?=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../property_overrides/water_heating_guard.py | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/domain/epc/property_overrides/water_heating_guard.py b/domain/epc/property_overrides/water_heating_guard.py index 4b447ff6e..1970f6bfd 100644 --- a/domain/epc/property_overrides/water_heating_guard.py +++ b/domain/epc/property_overrides/water_heating_guard.py @@ -6,4 +6,36 @@ from domain.epc.property_overrides.water_heating_type import WaterHeatingType def water_heating_guard(description: str) -> Optional[WaterHeatingType]: - raise NotImplementedError + """Deterministically resolve the structured water-heating descriptions the LLM + funnelled into the ``"From main system, house coal"`` dumping ground (#1376). + + Landlord water-heating descriptions arrive as ``": "`` (e.g. + ``"From main heating system: Wood Logs"``). Where the taxonomy had no biomass / + wood / dual-fuel / biodiesel water fuel, the classifier force-picked house coal, + scoring a biomass dwelling's DHW at ~14x its carbon (ADR-0043). This guard keys + on the **fuel token** and returns the faithful archetype — the ``"Hot-water only + community scheme"`` system flattens to ``"From main system, …"`` exactly as the + community mains-gas description already does. ``"No Heating or Hot Water"`` under + an ``"electric immersion assumed"`` system is the assessment's own immersion + assumption, so it resolves to ``ELECTRIC_IMMERSION``. + + Returns ``None`` for fuels the LLM already classifies correctly (mains gas, + electricity, oil, …) and for varied / unstructured phrasings, so those still + reach the LLM classifier via ``GuardedColumnClassifier``. Order matters: + biodiesel and dual fuel are tested before the bare biomass / wood tokens they + contain. + """ + text = description.lower() + if "biodiesel" in text: + return WaterHeatingType.FROM_MAIN_BIODIESEL_COMMUNITY + if "biomass" in text: + return WaterHeatingType.FROM_MAIN_BIOMASS_COMMUNITY + if "dual fuel" in text: + return WaterHeatingType.FROM_MAIN_DUAL_FUEL_MINERAL_WOOD + if "wood log" in text: + return WaterHeatingType.FROM_MAIN_WOOD_LOGS + if "house coal" in text: + return WaterHeatingType.FROM_MAIN_HOUSE_COAL + if "no heating or hot water" in text: + return WaterHeatingType.ELECTRIC_IMMERSION + return None