Deterministically guard structured biomass and immersion water-heating descriptions 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-01 13:06:52 +00:00
parent d7f069b7c5
commit d0aa596ae7

View file

@ -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 ``"<system>: <fuel>"`` (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