mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
section 4
This commit is contained in:
parent
df4b5a8933
commit
d03341bbb2
2 changed files with 56 additions and 29 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from etl.pdfReader.reportType import ReportType
|
||||
from transform.types import CompanyInfo, SurverySummaryInfo, AssessorInfo, PropertyDescription, PropertyDetail
|
||||
from transform.types import CompanyInfo, SurverySummaryInfo, AssessorInfo, PropertyDescription, PropertyDetail, Dimension
|
||||
from datetime import datetime
|
||||
|
||||
class SiteNotesExtractor():
|
||||
|
|
@ -178,15 +178,29 @@ class QuidosSiteNotesExtractor(SiteNotesExtractor):
|
|||
# Section 3
|
||||
age_bands = self.get_age_band()
|
||||
|
||||
# Section 4
|
||||
no_of_main_property = int(get_value("Main Property"))
|
||||
no_of_extension_1 = int(get_value('Extension 1') or 0)
|
||||
no_of_extension_2 = int(get_value('Extension 2') or 0)
|
||||
no_of_extension_3 = int(get_value('Extension 3') or 0)
|
||||
no_of_extension_4 = int(get_value('Extension 4') or 0)
|
||||
dimensions = self.get_dimensions(
|
||||
no_of_main_property,
|
||||
no_of_extension_1,
|
||||
no_of_extension_2,
|
||||
no_of_extension_3,
|
||||
no_of_extension_4,
|
||||
)
|
||||
|
||||
|
||||
self.property_description = PropertyDescription(
|
||||
built_form = get_value("Built Form"),
|
||||
detachment_or_position = get_value("Detachment/Position"),
|
||||
no_of_main_property = int(get_value("Main Property")),
|
||||
no_of_extension_1 = int(get_value('Extension 1') or 0),
|
||||
no_of_extension_2 = int(get_value('Extension 2') or 0),
|
||||
no_of_extension_3 = int(get_value('Extension 3') or 0),
|
||||
no_of_extension_4 = int(get_value('Extension 4') or 0),
|
||||
no_of_main_property = no_of_main_property,
|
||||
no_of_extension_1 = no_of_extension_1,
|
||||
no_of_extension_2 = no_of_extension_2,
|
||||
no_of_extension_3 = no_of_extension_3,
|
||||
no_of_extension_4 = no_of_extension_4,
|
||||
no_of_habitable_rooms = int(get_value('Number of Habitable Rooms')),
|
||||
no_of_heated_rooms = int(get_value('Number of Heated Habitable Rooms')),
|
||||
heated_basement = False if get_value('Heated Basement') == "NO" else True,
|
||||
|
|
@ -194,17 +208,21 @@ class QuidosSiteNotesExtractor(SiteNotesExtractor):
|
|||
terrain_type = get_value('Terrain Type'),
|
||||
percentage_of_draught_proofed= int(get_value('Percentage of Draught Proofed(%)')),
|
||||
main_property=PropertyDetail(
|
||||
age_band= age_bands[0]
|
||||
)if age_bands[0] else None,
|
||||
age_band= age_bands[0],
|
||||
dimensions= dimensions["main"] if "main" in dimensions else [],
|
||||
)if no_of_main_property > 0 else None,
|
||||
ex1_property=PropertyDetail(
|
||||
age_band= age_bands[1]
|
||||
)if age_bands[1] else None,
|
||||
age_band= age_bands[1],
|
||||
dimensions= dimensions["ex1"] if "ex1" in dimensions else [],
|
||||
)if no_of_extension_1 > 0 else None,
|
||||
ex2_property=PropertyDetail(
|
||||
age_band= age_bands[2]
|
||||
)if age_bands[2] else None,
|
||||
age_band= age_bands[2],
|
||||
dimensions= dimensions["ex2"] if "ex2" in dimensions else [],
|
||||
)if no_of_extension_2 > 0 else None,
|
||||
ex3_property=PropertyDetail(
|
||||
age_band= age_bands[3]
|
||||
)if age_bands[3] else None,
|
||||
age_band= age_bands[3],
|
||||
dimensions=dimensions["ex3"] if "ex3" in dimensions else [],
|
||||
)if no_of_extension_4 > 0 else None,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -239,8 +257,9 @@ class QuidosSiteNotesExtractor(SiteNotesExtractor):
|
|||
return property_age
|
||||
|
||||
|
||||
def get_section_4(self, no_of_main_property):
|
||||
def get_dimensions(self, main, ext1=0, ext2=0, ext3=0, ext4=0):
|
||||
data = self.get_data_between('4.0 Dimensions','5.0 Conservatory')
|
||||
|
||||
avoid = [
|
||||
'4.0 Dimensions',
|
||||
'5.0 Conservatory',
|
||||
|
|
@ -256,6 +275,7 @@ class QuidosSiteNotesExtractor(SiteNotesExtractor):
|
|||
'Extension 3 Property',
|
||||
'Extension 4 Property',
|
||||
]
|
||||
|
||||
def create_dimensions_array(key, no_of_property):
|
||||
index = data.index(key) + 1
|
||||
|
||||
|
|
@ -264,25 +284,25 @@ class QuidosSiteNotesExtractor(SiteNotesExtractor):
|
|||
numbers = []
|
||||
for i in range(4):
|
||||
numbers.append(data[i + propertyNo*4 + index])
|
||||
details = {
|
||||
"Floor Area (m2)": numbers[0],
|
||||
"Room Height (m)": numbers[1],
|
||||
"Loss Perimeter (m)": numbers[2],
|
||||
"Party Wall Length (m)": numbers[3],
|
||||
}
|
||||
details = Dimension(
|
||||
floor_area_m2=float(numbers[0]),
|
||||
room_height_m=float(numbers[1]),
|
||||
loss_perimeter_m=float(numbers[2]),
|
||||
party_wall_length_m=float(numbers[3]),
|
||||
)
|
||||
allNumbers.append(details)
|
||||
return allNumbers
|
||||
|
||||
return_dict = {}
|
||||
|
||||
return_dict.update({"main": create_dimensions_array("Main Property", main)})
|
||||
|
||||
if "Main Property" in data:
|
||||
self.main_property_dimensions = create_dimensions_array("Main Property", no_of_main_property)
|
||||
else:
|
||||
self.main_property_dimensions = None
|
||||
ext = [ext1, ext2, ext3, ext4]
|
||||
|
||||
for i in range(1,5):
|
||||
if self.extension_1 and f"Extension {i} Property" in data:
|
||||
setattr(self, f"extension_{i}_dimensions)", create_dimensions_array(f"Extension {i} Property", int(getattr(self, f"extension_{i}"))))
|
||||
else:
|
||||
setattr(self, f"extensions_{i}_dimensions",None)
|
||||
if f"Extension {i} Property" in data:
|
||||
return_dict.update({f"ex{i}" : create_dimensions_array(f"Extension {i} Property", ext[i-1])})
|
||||
return return_dict
|
||||
|
||||
def get_section_5(self):
|
||||
data = self.raw_data[self.raw_data.index('5.0 Conservatory'):self.raw_data.index('7.0 Walls')]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@ from typing import Optional, List
|
|||
import re
|
||||
from datetime import datetime
|
||||
|
||||
class Dimension(BaseModel):
|
||||
floor_area_m2: float
|
||||
room_height_m: float
|
||||
loss_perimeter_m: float
|
||||
party_wall_length_m: float
|
||||
|
||||
class CompanyInfo(BaseModel):
|
||||
trading_name: str
|
||||
post_code: str
|
||||
|
|
@ -44,6 +50,7 @@ class AssessorInfo(BaseModel):
|
|||
|
||||
class PropertyDetail(BaseModel):
|
||||
age_band: str
|
||||
dimensions: List[Dimension] = []
|
||||
|
||||
class PropertyDescription(BaseModel):
|
||||
built_form: str
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue