Model/model_data/epc_attributes/LightingAttributes.py
2023-07-03 18:31:49 +01:00

38 lines
1.3 KiB
Python

import re
from model_data.epc_attributes.attribute_utils import clean_description
from model_data.utils import correct_spelling
class LightingAttributes:
def __init__(self, description, averages):
self.description: str = clean_description(description.lower())
self.description = correct_spelling(self.description)
self.averages = averages
def process(self):
description = self.description
if 'no low energy lighting' in description:
return {"low_energy_proportion": 0}
if "all fixed outlets" in description:
return {"low_energy_proportion": 1}
if ('good lighting efficiency' in description) or ('excellent lighting efficiency' in description) or \
('below average lighting efficiency' in description):
return {
"low_energy_proportion": self.averages[
self.averages["lighting-description"] == description
]["low-energy-lighting"].values[0]
}
match = re.search(r'\d+', description)
if match:
proportion = int(match.group()) / 100.0
return {
"low_energy_proportion": proportion
}
raise NotImplementedError("Not handled this case - investigate me")