mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
59 lines
2.4 KiB
Python
59 lines
2.4 KiB
Python
import re
|
|
from typing import Dict, Union
|
|
|
|
|
|
class WallAttributes:
|
|
|
|
def __init__(self, description: str):
|
|
"""
|
|
:param description: Description of the walls.
|
|
"""
|
|
self.description: str = description
|
|
|
|
def process(self) -> Dict[str, Union[float, str, bool, None]]:
|
|
result: Dict[str, Union[float, str, bool, None]] = {}
|
|
description = self.description.lower()
|
|
|
|
# thermal transmittance - it can be negative which is errneous however we'll still pull it out
|
|
match = re.search(r"average thermal transmittance (-?\d+\.\d+)\s(w/m-¦k)", description)
|
|
if match:
|
|
result['thermal_transmittance'] = float(match.group(1))
|
|
result['thermal_transmittance_unit'] = match.group(2)
|
|
else:
|
|
result['thermal_transmittance'] = None
|
|
result['thermal_transmittance_unit'] = None
|
|
|
|
# wall type
|
|
result['is_cavity_wall'] = 'cavity wall' in description
|
|
result['has_filled_cavity'] = 'filled cavity' in description
|
|
result['is_solid_brick'] = 'solid brick' in description
|
|
result['is_system_built'] = 'system built' in description
|
|
result['is_timber_frame'] = 'timber frame' in description
|
|
result['is_granite_or_whinstone'] = 'granite' in description or 'whinstone' in description
|
|
result['as_built'] = 'as built' in description
|
|
result['is_cob'] = 'cob' in description
|
|
result['assumed'] = 'assumed' in description
|
|
result['is_sandstone_or_limestone'] = 'sandstone or limestone' in description
|
|
|
|
# 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
|