mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
from typing import Dict, Union
|
|
from epc_data.attributes.attribute_utils import clean_description, remove_punctuation, find_keyword
|
|
|
|
|
|
class HotWaterAttributes:
|
|
HEATER_TYPES = [
|
|
'gas instantaneous',
|
|
'electric heat pump',
|
|
'electric immersion',
|
|
'gas boiler',
|
|
'electric instantaneous',
|
|
'gas multipoint',
|
|
]
|
|
|
|
SYSTEM_TYPES = [
|
|
'from main system',
|
|
'from secondary system',
|
|
'community scheme',
|
|
]
|
|
|
|
THERMOSTAT_CHARACTERISTICS = [
|
|
'no cylinder thermostat',
|
|
]
|
|
|
|
HEATING_SCOPE = [
|
|
'water heating only',
|
|
]
|
|
|
|
OTHER_CHARACTERISTICS = [
|
|
'waste water heat recovery',
|
|
'plus solar',
|
|
'off-peak',
|
|
'flue gas heat recovery',
|
|
'standard tariff',
|
|
'chp',
|
|
]
|
|
|
|
NO_SYSTEM_PRESENT_KEYWORDS = [
|
|
'no system present',
|
|
]
|
|
|
|
def __init__(self, description: str):
|
|
self.description: str = clean_description(description.lower())
|
|
|
|
if not any(
|
|
self._keyword_in_description(keywords)
|
|
for keywords in [
|
|
self.HEATER_TYPES,
|
|
self.SYSTEM_TYPES,
|
|
self.THERMOSTAT_CHARACTERISTICS,
|
|
self.HEATING_SCOPE,
|
|
self.OTHER_CHARACTERISTICS,
|
|
self.NO_SYSTEM_PRESENT_KEYWORDS,
|
|
]
|
|
):
|
|
raise ValueError('Invalid description')
|
|
|
|
def _keyword_in_description(self, keywords):
|
|
return any(keyword in self.description for keyword in keywords)
|
|
|
|
def process(self) -> Dict[str, Union[str, bool]]:
|
|
result: Dict[str, Union[str, bool]] = {
|
|
"heater_type": find_keyword(self.description, self.HEATER_TYPES),
|
|
"system_type": find_keyword(self.description, self.SYSTEM_TYPES),
|
|
"thermostat_characteristics": find_keyword(self.description, self.THERMOSTAT_CHARACTERISTICS),
|
|
"heating_scope": find_keyword(self.description, self.HEATING_SCOPE),
|
|
"other_characteristics": [find_keyword(self.description, [keyword]) for keyword in
|
|
self.OTHER_CHARACTERISTICS if find_keyword(self.description, [keyword])],
|
|
"no_system_present": find_keyword(self.description, self.NO_SYSTEM_PRESENT_KEYWORDS),
|
|
}
|
|
|
|
return result
|