mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
new lambda dep[loy
This commit is contained in:
parent
9419175ca5
commit
33f03644d5
3 changed files with 41 additions and 15 deletions
|
|
@ -57,7 +57,7 @@ def serialize_model(model: Any):
|
|||
else:
|
||||
return model
|
||||
|
||||
def make_final_json(rooms_obj, heating_system_obj, occupant, access_and_elevations):
|
||||
def make_final_json(rooms_obj, heating_system_obj, occupant, access_and_elevations, bepoke_info):
|
||||
# Convert to dict recursively
|
||||
rooms_data = serialize_model(rooms_obj)
|
||||
heating_data = serialize_model(heating_system_obj)
|
||||
|
|
@ -70,6 +70,7 @@ def make_final_json(rooms_obj, heating_system_obj, occupant, access_and_elevatio
|
|||
"heating_system": heating_data,
|
||||
"occupant_info": occupant_data,
|
||||
"access_and_elevations": access_and_elevations_data,
|
||||
"bespoke_data": bepoke_info
|
||||
}
|
||||
|
||||
# Convert to pretty JSON string
|
||||
|
|
@ -203,19 +204,20 @@ def handler(event, context):
|
|||
local_path = download_private_s3_file(file_uri)
|
||||
|
||||
# Local development of file, please comment out for prod
|
||||
# local_path = os.path.join(os.path.join(os.getcwd(), "../../../../../", "home/Downloads/works/26-Marden-Road.pdf"))
|
||||
local_path = os.path.join(os.path.join(os.getcwd(), "../../../../../", "home/Downloads/works/67-Aylestone-Road-1.pdf"))
|
||||
|
||||
|
||||
|
||||
print("Extracting file...")
|
||||
reader = pdfReaderToText(local_path)
|
||||
# obj2 = WarmHomesConditionReport(reader.text_list, debug=True)
|
||||
obj2 = WarmHomesConditionReport(reader.text_list, debug=True)
|
||||
obj = WarmHomesConditionReport(reader.text_list)
|
||||
json_ = make_final_json(
|
||||
obj.master_obj[0],
|
||||
obj.master_obj[1],
|
||||
obj.master_obj[2],
|
||||
obj.master_obj[3],
|
||||
{}
|
||||
)
|
||||
print("Extracted completed, made json")
|
||||
|
||||
|
|
|
|||
|
|
@ -347,12 +347,23 @@ class WarmHomesConditionReport(SiteNotesExtractor):
|
|||
)
|
||||
|
||||
def get_room_info(self, data):
|
||||
ventilation = VentilationInfo(
|
||||
is_there_a_ventilation_system_present_in_the_room=True if self.get_next_value(data, "Is there a ventilation system present in the room?").lower() == "yes" else False,
|
||||
are_there_any_visible_or_reported_signs_of_damp_mould_or_excessive_condensation_within_the_room=True if self.get_next_value(data, "excessive condensation within the room?").lower() == "yes" else False,
|
||||
are_there_sufficient_undercuts_on_the_closed_door=self.get_next_value(data, "- min 10mm)?"),
|
||||
is_there_any_open_flue_heating_appliances_within_the_room=True if self.get_next_value(data, "Is there any open flue heating appliances within the room?").lower() == "yes" else False,
|
||||
)
|
||||
state = True if self.get_next_value(data, "excessive condensation within the room?").lower() == "yes" else False
|
||||
if state is False:
|
||||
ventilation = VentilationInfo(
|
||||
is_there_a_ventilation_system_present_in_the_room=True if self.get_next_value(data, "Is there a ventilation system present in the room?").lower() == "yes" else False,
|
||||
are_there_any_visible_or_reported_signs_of_damp_mould_or_excessive_condensation_within_the_room=True if self.get_next_value(data, "excessive condensation within the room?").lower() == "yes" else False,
|
||||
are_there_sufficient_undercuts_on_the_closed_door=self.get_next_value(data, "- min 10mm)?"),
|
||||
is_there_any_open_flue_heating_appliances_within_the_room=True if self.get_next_value(data, "Is there any open flue heating appliances within the room?").lower() == "yes" else False,
|
||||
)
|
||||
else:
|
||||
ventilation = VentilationInfo(
|
||||
is_there_a_ventilation_system_present_in_the_room=True if self.get_next_value(data, "Is there a ventilation system present in the room?").lower() == "yes" else False,
|
||||
are_there_any_visible_or_reported_signs_of_damp_mould_or_excessive_condensation_within_the_room=True if self.get_next_value(data, "excessive condensation within the room?").lower() == "yes" else False,
|
||||
are_there_sufficient_undercuts_on_the_closed_door=self.get_next_value(data, "- min 10mm)?"),
|
||||
is_there_any_open_flue_heating_appliances_within_the_room=True if self.get_next_value(data, "Is there any open flue heating appliances within the room?").lower() == "yes" else False,
|
||||
location_of_any_damp_or_mould=self.get_next_value(data, "Location of any damp/mould")
|
||||
)
|
||||
|
||||
|
||||
windows_state = True if self.get_next_value(data, "Does the room have any windows?").lower() == "yes" else False
|
||||
if windows_state:
|
||||
|
|
@ -368,12 +379,23 @@ class WarmHomesConditionReport(SiteNotesExtractor):
|
|||
does_the_room_have_any_windows=windows_state
|
||||
)
|
||||
|
||||
return RoomInfo(
|
||||
overall_condition_of_the_room=self.get_next_value(data, "Overall condition of the room"),
|
||||
does_the_room_have_any_defects=self.get_next_value(data, "cracking in walls, etc.)"),
|
||||
windows_info=windows,
|
||||
ventilation_info=ventilation,
|
||||
)
|
||||
state = True if self.get_next_value(data, "cracking in walls, etc.)").lower()=="yes" else False
|
||||
if state:
|
||||
return RoomInfo(
|
||||
overall_condition_of_the_room=self.get_next_value(data, "Overall condition of the room"),
|
||||
does_the_room_have_any_defects=self.get_next_value(data, "cracking in walls, etc.)"),
|
||||
description_of_defect=self.get_next_value(data, "Description of the defects", avoid=["Any additional recommendations?"]),
|
||||
windows_info=windows,
|
||||
ventilation_info=ventilation,
|
||||
)
|
||||
else:
|
||||
return RoomInfo(
|
||||
overall_condition_of_the_room=self.get_next_value(data, "Overall condition of the room"),
|
||||
does_the_room_have_any_defects=self.get_next_value(data, "cracking in walls, etc.)"),
|
||||
windows_info=windows,
|
||||
ventilation_info=ventilation,
|
||||
)
|
||||
|
||||
|
||||
|
||||
def get_hallway(self):
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class VentilationInfo(BaseModel):
|
|||
are_there_any_visible_or_reported_signs_of_damp_mould_or_excessive_condensation_within_the_room: bool
|
||||
are_there_sufficient_undercuts_on_the_closed_door: str
|
||||
is_there_any_open_flue_heating_appliances_within_the_room: bool
|
||||
location_of_any_damp_or_mould: Optional[str] = ""
|
||||
|
||||
class WindowsInfo(BaseModel):
|
||||
does_the_room_have_any_windows: bool
|
||||
|
|
@ -104,6 +105,7 @@ class WindowsInfo(BaseModel):
|
|||
class RoomInfo(BaseModel):
|
||||
overall_condition_of_the_room: str
|
||||
does_the_room_have_any_defects: str
|
||||
description_of_defect: Optional[str] = ""
|
||||
are_there_any_sloped_ceiling_areas: Optional[bool] = None
|
||||
windows_info: Optional[WindowsInfo] = None
|
||||
ventilation_info: Optional[VentilationInfo] = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue