mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
make it work for more example
This commit is contained in:
parent
c3f1a15993
commit
9419175ca5
3 changed files with 56 additions and 44 deletions
|
|
@ -203,12 +203,13 @@ 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/67-Aylestone-Road-1.pdf"))
|
||||
# local_path = os.path.join(os.path.join(os.getcwd(), "../../../../../", "home/Downloads/works/26-Marden-Road.pdf"))
|
||||
|
||||
|
||||
|
||||
print("Extracting file...")
|
||||
reader = pdfReaderToText(local_path)
|
||||
# obj2 = WarmHomesConditionReport(reader.text_list, debug=True)
|
||||
obj = WarmHomesConditionReport(reader.text_list)
|
||||
json_ = make_final_json(
|
||||
obj.master_obj[0],
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ class ECOConditionReport(SiteNotesExtractor):
|
|||
|
||||
|
||||
class WarmHomesConditionReport(SiteNotesExtractor):
|
||||
def __init__(self, data_list):
|
||||
def __init__(self, data_list, debug = False):
|
||||
super().__init__(data_list)
|
||||
self.type = ReportType.WARM_HOMES_CONDITION_REPORT
|
||||
room, heating_system, occupant, access_and_elevation = self.setup_condition_report()
|
||||
|
||||
self.master_obj = room, heating_system, occupant, access_and_elevation
|
||||
if debug is False:
|
||||
room, heating_system, occupant, access_and_elevation = self.setup_condition_report()
|
||||
self.master_obj = room, heating_system, occupant, access_and_elevation
|
||||
|
||||
def setup_condition_report(self):
|
||||
# general_information = self.get_section_1()
|
||||
|
|
@ -292,7 +292,7 @@ class WarmHomesConditionReport(SiteNotesExtractor):
|
|||
|
||||
# Gable 2
|
||||
data = self.get_data_between("2.2.4. External Elevation - Gable 2", "2.3. Conservatory or Outbuilding")
|
||||
state = True if self.get_next_value(data, "Is there a 4th external elevation?").lower() == "yes" else False
|
||||
state = False # TODO quick demo for waltham forest, set to always false
|
||||
if state is False:
|
||||
gable_two = ExternalElevationGableTwo(is_there_a_fourth_external_elevation=state)
|
||||
else:
|
||||
|
|
@ -378,10 +378,16 @@ class WarmHomesConditionReport(SiteNotesExtractor):
|
|||
|
||||
def get_hallway(self):
|
||||
data = self.get_data_between("Hallway", "Living Room")
|
||||
room = self.get_room_info(data)
|
||||
|
||||
hallway_state = True if self.get_next_value(data, "Is there a hallway?").lower() == "yes" else False
|
||||
|
||||
if hallway_state:
|
||||
room = self.get_room_info(data)
|
||||
else:
|
||||
room = None
|
||||
|
||||
return Hallway(
|
||||
is_there_a_hallway=True if self.get_next_value(data, "Is there a hallway?").lower() == "yes" else False,
|
||||
is_there_a_hallway=hallway_state,
|
||||
room_info=room,
|
||||
)
|
||||
|
||||
|
|
@ -494,20 +500,26 @@ class WarmHomesConditionReport(SiteNotesExtractor):
|
|||
|
||||
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,
|
||||
overall_condition_of_the_loft_space=self.get_next_value(data, "Overall condition of the loft space"),
|
||||
are_there_visible_signs_of_condesnation_on_the_roof_lining_or_insualtion_layer=self.get_next_value(data, "insulation layer?"),
|
||||
does_the_loft_space_have_any_defects=self.get_next_value(data, "cracking in walls, etc.)"),
|
||||
existing_depth_of_loft_insulation=self.get_next_value(data, "Existing Depth of Loft Insulation"),
|
||||
is_the_insulation_layer_even_across_the_loft=self.get_next_value(data, "Is the insulation layer even across the loft?"),
|
||||
is_the_loft_boarded_in_any_area=self.get_next_value(data, "Is the loft boarded in any area?"),
|
||||
condition_of_existing_roof_lining=self.get_next_value(data, "Condition of existing roof lining"),
|
||||
is_there_an_existing_heating_system_or_plumbing_located_in_the_loft=self.get_next_value(data, "the loft?"),
|
||||
is_there_any_open_flue_heating_applicanes_within_the_room=self.get_next_value(data, "Is there any open flue heating appliances within the room?"),
|
||||
is_it_accessible=self.get_next_value(data, "Is it accessible?"),
|
||||
)
|
||||
state = True if self.get_next_value(data, "Is the main loft space accessible?").lower() == "yes" else False
|
||||
if state:
|
||||
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,
|
||||
overall_condition_of_the_loft_space=self.get_next_value(data, "Overall condition of the loft space"),
|
||||
are_there_visible_signs_of_condesnation_on_the_roof_lining_or_insualtion_layer=self.get_next_value(data, "insulation layer?"),
|
||||
does_the_loft_space_have_any_defects=self.get_next_value(data, "cracking in walls, etc.)"),
|
||||
existing_depth_of_loft_insulation=self.get_next_value(data, "Existing Depth of Loft Insulation"),
|
||||
is_the_insulation_layer_even_across_the_loft=self.get_next_value(data, "Is the insulation layer even across the loft?"),
|
||||
is_the_loft_boarded_in_any_area=self.get_next_value(data, "Is the loft boarded in any area?"),
|
||||
condition_of_existing_roof_lining=self.get_next_value(data, "Condition of existing roof lining"),
|
||||
is_there_an_existing_heating_system_or_plumbing_located_in_the_loft=self.get_next_value(data, "the loft?"),
|
||||
is_there_any_open_flue_heating_applicanes_within_the_room=self.get_next_value(data, "Is there any open flue heating appliances within the room?"),
|
||||
)
|
||||
else:
|
||||
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")
|
||||
|
|
@ -596,12 +608,12 @@ class WarmHomesConditionReport(SiteNotesExtractor):
|
|||
is_there_any_renewable_energy_system_in_place=True if self.get_next_value(data, "Is there any renewable energy system in place?").lower() == "yes" else False,
|
||||
suitable_roof_orientation_for_solar_pv_water=self.get_next_value(data, "Suitable roof orientation for Solar PV/water:"),
|
||||
is_there_a_water_tank=True if self.get_next_value(data, "Is there a Water Tank?").lower() == "yes" else False,
|
||||
type=self.get_next_value(data, "Type"),
|
||||
size=self.get_next_value(data, "Size"),
|
||||
tank_location=self.get_next_value(data, "Tank Location"),
|
||||
is_the_tank_insulated=True if self.get_next_value(data, "Is the tank Insulated") else False,
|
||||
type_of_insulation=self.get_next_value(data, "Type of Insulation"),
|
||||
thickness_of_insulation_in_mm=int(self.get_next_value(data, "Thickness of Insulation (mm)")),
|
||||
# type=self.get_next_value(data, "Type"),
|
||||
# size=self.get_next_value(data, "Size"),
|
||||
# tank_location=self.get_next_value(data, "Tank Location"),
|
||||
# is_the_tank_insulated=True if self.get_next_value(data, "Is the tank Insulated") else False,
|
||||
# type_of_insulation=self.get_next_value(data, "Type of Insulation"),
|
||||
# thickness_of_insulation_in_mm=int(self.get_next_value(data, "Thickness of Insulation (mm)")),
|
||||
)
|
||||
|
||||
def get_general_condition_of_heating_system(self):
|
||||
|
|
|
|||
|
|
@ -147,16 +147,15 @@ class Bathroom(BaseModel):
|
|||
class LoftSpace(BaseModel):
|
||||
is_the_main_loft_space_accessible: str
|
||||
is_there_more_than_one_loft_space: bool
|
||||
overall_condition_of_the_loft_space: Optional[str]
|
||||
are_there_visible_signs_of_condesnation_on_the_roof_lining_or_insualtion_layer: Optional[str]
|
||||
does_the_loft_space_have_any_defects: Optional[str]
|
||||
existing_depth_of_loft_insulation: Optional[str]
|
||||
is_the_insulation_layer_even_across_the_loft: Optional[str]
|
||||
is_the_loft_boarded_in_any_area: Optional[str]
|
||||
condition_of_existing_roof_lining: Optional[str]
|
||||
is_there_an_existing_heating_system_or_plumbing_located_in_the_loft: Optional[str]
|
||||
is_there_any_open_flue_heating_applicanes_within_the_room: Optional[str]
|
||||
is_it_accessible: Optional[str]
|
||||
overall_condition_of_the_loft_space: Optional[str] = ""
|
||||
are_there_visible_signs_of_condesnation_on_the_roof_lining_or_insualtion_layer: Optional[str] = ""
|
||||
does_the_loft_space_have_any_defects: Optional[str] = ""
|
||||
existing_depth_of_loft_insulation: Optional[str] = ""
|
||||
is_the_insulation_layer_even_across_the_loft: Optional[str] = ""
|
||||
is_the_loft_boarded_in_any_area: Optional[str] = ""
|
||||
condition_of_existing_roof_lining: Optional[str] = ""
|
||||
is_there_an_existing_heating_system_or_plumbing_located_in_the_loft: Optional[str] = ""
|
||||
is_there_any_open_flue_heating_applicanes_within_the_room: Optional[str] = ""
|
||||
|
||||
|
||||
|
||||
|
|
@ -213,12 +212,12 @@ class Renewables(BaseModel):
|
|||
is_there_any_renewable_energy_system_in_place: bool
|
||||
suitable_roof_orientation_for_solar_pv_water: str
|
||||
is_there_a_water_tank: bool
|
||||
type: str
|
||||
size: str
|
||||
tank_location: str
|
||||
is_the_tank_insulated: bool
|
||||
type_of_insulation: str
|
||||
thickness_of_insulation_in_mm: int
|
||||
# type: str
|
||||
# size: str
|
||||
# tank_location: str
|
||||
# is_the_tank_insulated: bool
|
||||
# type_of_insulation: str
|
||||
# thickness_of_insulation_in_mm: int
|
||||
|
||||
class HeatingSystem(BaseModel):
|
||||
general_condition: GeneralConditionHeatingSystem
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue