mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
52 lines
2.1 KiB
Python
52 lines
2.1 KiB
Python
from typing import Dict, Union
|
|
from model_data.BaseUtility import BaseUtility
|
|
from model_data.epc_attributes.attribute_utils import extract_component_types, extract_thermal_transmittance
|
|
|
|
|
|
class WallAttributes(BaseUtility):
|
|
WALL_TYPES = ['cavity wall', 'filled cavity', 'solid brick', 'system built', 'timber frame', 'granite or whinstone',
|
|
'as built', 'cob', 'assumed', 'sandstone or limestone']
|
|
|
|
def __init__(self, description: str):
|
|
"""
|
|
:param description: Description of the walls.
|
|
"""
|
|
self.description: str = description
|
|
|
|
self.nodata = not description or description in self.DATA_ANOMALY_MATCHES
|
|
|
|
def process(self) -> Dict[str, Union[float, str, bool, None]]:
|
|
result: Dict[str, Union[float, str, bool, None]] = {}
|
|
if self.nodata:
|
|
return result
|
|
|
|
description = self.description.lower()
|
|
|
|
# thermal transmittance - it can be negative which is errneous however we'll still pull it out
|
|
result, description = extract_thermal_transmittance(result, description)
|
|
|
|
# wall type
|
|
result, description = extract_component_types(result, description, list_of_components=self.WALL_TYPES)
|
|
|
|
# insulation thickness - this is far from a perfect approach and we'd likely need to use nlp to do this
|
|
# generally however this is sufficient for mvp
|
|
thickness_map = {
|
|
"external insulation": "average",
|
|
"internal insulation": "average",
|
|
"partial insulation": "below average",
|
|
"no insulation": "none",
|
|
"additional insulation": "above average",
|
|
"insulated": "average"
|
|
}
|
|
for key, value in thickness_map.items():
|
|
if key in description:
|
|
result['insulation_thickness'] = value
|
|
break
|
|
else:
|
|
result['insulation_thickness'] = None
|
|
|
|
# insulation type
|
|
result['external_insulation'] = 'external insulation' in description
|
|
result['internal_insulation'] = 'internal insulation' in description
|
|
|
|
return result
|