Resolve a party-ceiling roof marker to the party-ceiling member 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-01 09:36:28 +00:00
parent 6fc10683d2
commit 87d0cc41ab

View file

@ -1,9 +1,23 @@
from __future__ import annotations
import re
from typing import Optional
from domain.epc.property_overrides.roof_type import RoofType
# The roof-type token (before any ``: <insulation>`` suffix), normalised to lower
# alphanumerics, → its party-ceiling RoofType member. Normalising strips spacing
# and case so both ``"another dwelling above"`` and ``"anotherdwellingabove"``
# match the same marker.
_PARTY_CEILING_MARKERS: dict[str, RoofType] = {
"anotherdwellingabove": RoofType.ADJACENT_ANOTHER_DWELLING_ABOVE,
}
def _normalise_roof_token(description: str) -> str:
token = description.split(":", 1)[0]
return re.sub(r"[^a-z0-9]", "", token.lower())
def roof_party_ceiling_guard(description: str) -> Optional[RoofType]:
"""Deterministically resolve a party-ceiling roof description to its RoofType.
@ -20,4 +34,4 @@ def roof_party_ceiling_guard(description: str) -> Optional[RoofType]:
that is not a party-ceiling marker so the LLM classifier still handles it
(#1376).
"""
raise NotImplementedError
return _PARTY_CEILING_MARKERS.get(_normalise_roof_token(description))