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