wrongmove/crawler/9_recalculate_regex_squaremeter.py
2024-03-25 20:48:48 +00:00

15 lines
535 B
Python

# recalculate regex from sqm from already previously ocr'ed text
import json
from rec.floorplan import extract_total_sqm
from tqdm import tqdm
from data_access import Listing
for listing in tqdm(list(Listing.get_all_listings())):
with open(listing.path_floorplan_ocr_json()) as f:
floorplans = json.load(f)
for floorplan in floorplans:
floorplan["estimated_sqm"] = extract_total_sqm(floorplan["text"])
with open(listing.path_floorplan_ocr_json(), "w") as f:
floorplans = json.dump(floorplans, f)