From 3ebda6277e1c31feef898ffb20482948f5979bf7 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 24 Sep 2024 20:53:24 +0100 Subject: [PATCH] fixing multiple translations and issues with epc descriptions --- .../epc_attributes/MainheatAttributes.py | 2 ++ .../epc_attributes/RoofAttributes.py | 27 ++++++++++--------- .../test_mainheat_attributes_cases.py | 17 +++++++++++- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/etl/epc_clean/epc_attributes/MainheatAttributes.py b/etl/epc_clean/epc_attributes/MainheatAttributes.py index bf86f573..c9f9fbe3 100644 --- a/etl/epc_clean/epc_attributes/MainheatAttributes.py +++ b/etl/epc_clean/epc_attributes/MainheatAttributes.py @@ -69,6 +69,8 @@ class MainHeatAttributes(Definitions): "portable electric heating assumed for most rooms": "portable electric heaters assumed for most rooms", "electric storage, electric": "electric storage heaters", "radiator heating, electric": "room heaters, electric", + "hot-water-only systems, gas": "no system present, electric heaters assumed", + "gas-fired heat pumps, electric": "air source heat pump, electric", } edge_case_result = {} diff --git a/etl/epc_clean/epc_attributes/RoofAttributes.py b/etl/epc_clean/epc_attributes/RoofAttributes.py index f3a4ee49..f36d445f 100644 --- a/etl/epc_clean/epc_attributes/RoofAttributes.py +++ b/etl/epc_clean/epc_attributes/RoofAttributes.py @@ -66,10 +66,18 @@ class RoofAttributes(Definitions): search for regular expressions and translate """ - loft_insulation_thickness_match = re.search(r"ar oleddf, (\d+ mm) o inswleiddio yn y llofft", self.description) - loft_insulation_thickness_match2 = re.search(r"ar oleddf, (\d+ mm) lo inswleiddio yn y llof", self.description) - loft_insulation_thickness_match3 = re.search(r"ar oleddf, (\d+\+ mm) lo inswleiddio yn y llof", - self.description) + loft_insulation_regexes = [ + r"ar oleddf, (\d+ mm) o inswleiddio yn y llofft", + r"ar oleddf, (\d+ mm) lo inswleiddio yn y llof", + r"ar oleddf, (\d+\+ mm) lo inswleiddio yn y llof", + r"ar oleddf, (\d+mm) o inswleiddio yn y llofft", + r"ar oleddf, (\d+\+ mm) o inswleiddio yn y llofft" + ] + li_thickness_match = None + for regex in loft_insulation_regexes: + li_thickness_match = re.search(regex, self.description) + if li_thickness_match: + break uvalue_search = re.search(r"trawsyriannedd thermol cyfartalog (\d+(\.\d+)?)\s*w/m-¦k", self.description) uvalue_search2 = re.search( @@ -77,15 +85,8 @@ class RoofAttributes(Definitions): ) # Step 2: Generalized translation with placeholder - if (loft_insulation_thickness_match is not None) | \ - (loft_insulation_thickness_match2 is not None) | \ - (loft_insulation_thickness_match3 is not None): - if loft_insulation_thickness_match is not None: - insulation_thickness = loft_insulation_thickness_match.group(1) - elif loft_insulation_thickness_match2 is not None: - insulation_thickness = loft_insulation_thickness_match2.group(1) - else: - insulation_thickness = loft_insulation_thickness_match3.group(1) + if li_thickness_match is not None: + insulation_thickness = li_thickness_match.group(1) self.description = f"pitched, {insulation_thickness} loft insulation" elif uvalue_search is not None or uvalue_search2 is not None: diff --git a/etl/epc_clean/tests/test_data/test_mainheat_attributes_cases.py b/etl/epc_clean/tests/test_data/test_mainheat_attributes_cases.py index 86175d4e..82675a74 100644 --- a/etl/epc_clean/tests/test_data/test_mainheat_attributes_cases.py +++ b/etl/epc_clean/tests/test_data/test_mainheat_attributes_cases.py @@ -1677,6 +1677,21 @@ mainheat_cases = [ 'has_coal': False, 'has_oil': False, 'has_wood_pellets': False, 'has_anthracite': False, 'has_dual_fuel_mineral_and_wood': False, 'has_smokeless_fuel': False, 'has_lpg': False, 'has_b30k': False, 'has_assumed': False, 'has_electricaire': False, 'has_assumed_for_most_rooms': False, - 'has_underfloor_heating': False} + 'has_underfloor_heating': False}, + { + 'original_description': 'Hot-Water-Only Systems, gas', + 'has_radiators': False, 'has_fan_coil_units': False, 'has_pipes_in_screed_above_insulation': False, + 'has_pipes_in_insulated_timber_floor': False, 'has_pipes_in_concrete_slab': False, 'has_boiler': False, + 'has_air_source_heat_pump': False, 'has_room_heaters': False, 'has_electric_storage_heaters': False, + 'has_warm_air': False, 'has_electric_underfloor_heating': False, 'has_electric_ceiling_heating': False, + 'has_community_scheme': False, 'has_ground_source_heat_pump': False, 'has_no_system_present': True, + 'has_portable_electric_heaters': False, 'has_water_source_heat_pump': False, 'has_electric_heat_pump': False, + 'has_micro-cogeneration': False, 'has_solar_assisted_heat_pump': False, 'has_exhaust_source_heat_pump': False, + 'has_community_heat_pump': False, 'has_electric': True, 'has_mains_gas': False, 'has_wood_logs': False, + 'has_coal': False, 'has_oil': False, 'has_wood_pellets': False, 'has_anthracite': False, + 'has_dual_fuel_mineral_and_wood': False, 'has_smokeless_fuel': False, 'has_lpg': False, 'has_b30k': False, + 'has_assumed': True, 'has_electricaire': False, 'has_assumed_for_most_rooms': False, + 'has_underfloor_heating': False + } ]