mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Legacy register fuel descriptions resolve to modern main_fuel codes 🟩
Strip the pre-RdSAP-17 deprecation rider and alias the SAP-prefixed forms before the code-table lookup. Raises the historic fuel resolution rate from ~22% of pairs to ~92% of dump rows. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
c79cd777e5
commit
1a11d0b900
1 changed files with 15 additions and 0 deletions
|
|
@ -84,6 +84,19 @@ _FUEL_CODES: dict[str, int] = {
|
|||
|
||||
_NOT_COMMUNITY_SUFFIX = " (not community)"
|
||||
|
||||
# Pre-RdSAP-17 lodgements carry a deprecation rider after the fuel name; the
|
||||
# fuel named is the same physical fuel. Dominant in the pre-2012 dump (a
|
||||
# 65-shard scan: 636/663 otherwise-unresolved values were these variants).
|
||||
_LEGACY_SUFFIX = " - this is for backwards compatibility only and should not be used"
|
||||
|
||||
# SAP-style lodgements prefix the category; map the known forms to the base
|
||||
# description the code table keys on.
|
||||
_LEGACY_ALIASES: dict[str, str] = {
|
||||
"Gas: mains gas": "mains gas",
|
||||
"Electricity: electricity, unspecified tariff": "electricity",
|
||||
"dual fuel - mineral + wood": "dual fuel (mineral and wood)",
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class HistoricConditioning:
|
||||
|
|
@ -105,6 +118,8 @@ def _wall_construction(description: str) -> Optional[int]:
|
|||
|
||||
def _main_fuel(description: str) -> Optional[int]:
|
||||
base = description.strip().removesuffix(_NOT_COMMUNITY_SUFFIX)
|
||||
base = base.removesuffix(_LEGACY_SUFFIX)
|
||||
base = _LEGACY_ALIASES.get(base, base)
|
||||
return _FUEL_CODES.get(base)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue