Ready to put together proper pipeline

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-08 12:46:14 +01:00
parent 6b86543ce4
commit 10c73aacef

View file

@ -50,7 +50,6 @@ def handler():
field = "roof-description"
unique_vals = Counter([v[field] for v in data])
pprint(unique_vals)
def search_description_options(desc):
if desc == "insulated":
@ -72,14 +71,22 @@ def handler():
return thickness
return int(thickness)
except ValueError as _:
if "invalid input" in description_lower:
return None
desc = description_lower.split("pitched,")[-1].lstrip().split(" ")[0]
return search_description_options(desc)
if is_roof_room:
desc_split_lookup = {
"ceiling insulated": "average",
"thatched": "average",
}
# Just search for specific phrases
desc_split = description_lower.split("roof room(s),")[-1].lstrip()
if desc_split == "ceiling insulated":
return "average"
res = desc_split_lookup.get(desc_split)
if res:
return res
desc = desc_split.split(" ")[0]
return search_description_options(desc)
@ -88,7 +95,7 @@ def handler():
desc = description_lower.split("flat,")[-1].lstrip().split(" ")[0]
return search_description_options(desc)
raise Exception("Unhandled")
return None
import re
def extract_thermal_transmittence(description_lower):
@ -123,7 +130,7 @@ def handler():
"""
description_lower = description.lower().lstrip().rstrip()
if "another dwelling above" in description_lower:
if "another dwelling above" in description_lower or "other premises above" in description_lower:
return {
"is_pitched": False,
"is_roof_room": False,
@ -132,6 +139,7 @@ def handler():
"has_dwelling_above": True,
"assumed": "assumed" in description_lower,
"is_flat": "flat" in description_lower,
"is_thatched": False,
"thermal_transmittence": None,
"thermal_transmittence_unit": None,
}
@ -140,12 +148,19 @@ def handler():
is_roof_room = "roof room" in description_lower
has_loft = "loft" in description_lower
is_flat = "flat" in description_lower
is_thatched = "thatched" in description_lower
thermal_transmittence, thermal_transmittence_unit, insulation_thickness = None, None, None
if "insulation" in description_lower or "insulated" in description_lower:
insulation_thickness = find_insulation_thickness(description_lower, is_pitched, is_roof_room, is_flat)
elif "thermal transmittance" in description_lower:
thermal_transmittence, thermal_transmittence_unit = extract_thermal_transmittence(description_lower)
elif is_thatched:
# Search for these features:
thermal_transmittence, thermal_transmittence_unit = extract_thermal_transmittence(description_lower)
insulation_thickness = find_insulation_thickness(
description_lower, is_pitched, is_roof_room, is_flat
)
else:
raise Exception("Implment me 2")