From d0315472fbd3e6e47dd3f5975e5a8b9013c82d3e Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Mon, 9 Jun 2025 16:19:00 +0000 Subject: [PATCH] finished section 3 --- etl/condition_report_etl.py | 2 +- etl/pdfReader/sitenotes.py | 62 ++++++++++++++++++++++++++- etl/transform/conditionReportTypes.py | 13 ++---- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/etl/condition_report_etl.py b/etl/condition_report_etl.py index bfc0cd3..1f035ad 100644 --- a/etl/condition_report_etl.py +++ b/etl/condition_report_etl.py @@ -1,3 +1,3 @@ from etl.surveyedData.surveryedData import surveyedDataProcessor condition_report_file_path = "/workspaces/survey-extractor/etl/files/osmosis_condition_report.pdf" -sdp = surveyedDataProcessor("123 Fake Street", [condition_report_file_path]) +sdp = surveyedDataProcessor("123 Fake Street", [condition_report_file_path]) \ No newline at end of file diff --git a/etl/pdfReader/sitenotes.py b/etl/pdfReader/sitenotes.py index 84589e9..57b5648 100644 --- a/etl/pdfReader/sitenotes.py +++ b/etl/pdfReader/sitenotes.py @@ -13,7 +13,7 @@ from etl.transform.conditionReportTypes import ( MainElevation, Elevation, ElevationInfo, PropertyAccess, ExternalElevation, ExternalElevationFront, ExternalElevationGableOne, ExternalElevationGableTwo, ExternalElevationRear, ConservatoryOrOutbuilding, AccessAndElevations, Hallway, RoomInfo, WindowsInfo, VentilationInfo, LivingRoom, DiningRoom, Kitchen, - Utility, WC, Landing + Utility, WC, Landing, Bedroom, Bathroom, LoftSpace, RoomInRoof ) from datetime import datetime from pprint import pprint @@ -284,6 +284,10 @@ class ConditionReport(SiteNotesExtractor): _ = self.get_wc() _ = self.get_landing() _ = self.get_bedrooms() + _ = self.get_bathroom() + _ = self.get_loft_space() + _ = self.get_room_in_roof() + pprint(_) def get_room_info(self, data): @@ -396,7 +400,61 @@ class ConditionReport(SiteNotesExtractor): ) def get_bedrooms(self): - pass + bedrooms = [] + i = 1 + while(f"Bedroom {i}" in self.raw_data): + i += 1 + + no_of_bedrooms = i-1 + print(f"There are {no_of_bedrooms} bedrooms") + + for i in range(no_of_bedrooms): + data = self.get_data_between(f"Bedroom {i+1}", "Bathroom") + roominfo = self.get_room_info(data) + bedrooms.append(Bedroom( + double_or_single_bedroom=self.get_next_value(data, "Double or Single Bedroom?"), + room_info=roominfo + )) + return bedrooms + + def get_bathroom(self): + bathrooms = [] + i = 1 + while(f"Bathroom {i}" in self.raw_data): + i += 1 + + no_of_bathrooms = i-1 + print(f"There are {no_of_bathrooms} bathrooms") + + for i in range(no_of_bathrooms): + data = self.get_data_between(f"Bathroom {i+1}", "Loft Space") + roominfo = self.get_room_info(data) + bathrooms.append(Bathroom( + is_this_an_ensuite_bathroom=self.get_next_value(data, "Is this an ensuite bathroom?"), + room_info=roominfo + )) + + return bathrooms + + def get_loft_space(self): + data = self.get_data_between("Loft Space", "Room in Roof") + return LoftSpace( + is_the_main_loft_space_accessible=self.get_next_value(data, "Is the main loft space accessible?"), + is_there_more_than_one_loft_space=True if self.get_next_value(data, "extension)?").lower() == "yes" else False, + ) + + def get_room_in_roof(self): + data = self.get_data_between("Room in Roof", "4. Heating System") + room_in_roof_state = True if self.get_next_value(data, "Is there a room in roof?").lower() == "yes" else False + room_info = None + if room_in_roof_state: + room_info = self.get_room_info(data) + return RoomInRoof( + is_there_a_room_in_roof=room_in_roof_state, + room_info=room_info + ) + + class QuidosSiteNotesExtractor(SiteNotesExtractor): diff --git a/etl/transform/conditionReportTypes.py b/etl/transform/conditionReportTypes.py index ff894d3..54accb8 100644 --- a/etl/transform/conditionReportTypes.py +++ b/etl/transform/conditionReportTypes.py @@ -142,16 +142,8 @@ class Bedroom(BaseModel): room_info: Optional[RoomInfo] class Bathroom(BaseModel): - is_this_an_ensuit_bathroom: bool - overall_condition_of_the_room: str - does_the_room_have_any_defects: bool - does_the_room_have_any_windows: bool - is_there_a_ventilation_system_present_in_the_room: str - is_the_ventilation_system_in_good_working_order: bool - extraction_ventilation_rate_measured: float - 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: bool - is_there_any_open_flue_heating_appliances_within_the_room: bool + is_this_an_ensuite_bathroom: bool + room_info: Optional[RoomInfo] class LoftSpace(BaseModel): is_the_main_loft_space_accessible: str @@ -159,6 +151,7 @@ class LoftSpace(BaseModel): class RoomInRoof(BaseModel): is_there_a_room_in_roof: bool + room_info: Optional[RoomInfo] class Rooms(BaseModel): hallway: Hallway