mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
initial implementation of HotWaterAttributes
This commit is contained in:
parent
fc15cce5bb
commit
23269bd03e
2 changed files with 61 additions and 1 deletions
|
|
@ -43,7 +43,7 @@ def handler():
|
|||
from epc_data.attributes.MainFuelAttributes import MainFuelAttributes
|
||||
from collections import Counter
|
||||
count = Counter([x["main-fuel"] for x in data])
|
||||
descriptions = {x["main-fuel"] for x in data}
|
||||
descriptions = {x["hotwater-description"] for x in data}
|
||||
out = []
|
||||
for description in descriptions:
|
||||
res = MainFuelAttributes(description).process()
|
||||
|
|
|
|||
60
epc_data/attributes/HotWaterAttributes.py
Normal file
60
epc_data/attributes/HotWaterAttributes.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
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',
|
||||
]
|
||||
|
||||
OTHER_CHARACTERISTICS = [
|
||||
'waste water heat recovery',
|
||||
'plus solar',
|
||||
'off-peak',
|
||||
'no cylinder thermostat',
|
||||
'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.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),
|
||||
"characteristics": find_keyword(self.description, self.OTHER_CHARACTERISTICS),
|
||||
"no_system_present": find_keyword(self.description, self.NO_SYSTEM_PRESENT_KEYWORDS),
|
||||
}
|
||||
|
||||
return result
|
||||
Loading…
Add table
Reference in a new issue