spb/toit-ka Public
Toit-Ka — louer ou acheter un toit au Québec, un seul endroit (fusion Lou-Ka × Immo-Ka) — www.toit-ka.com
Python 40.2%
TypeScript 39%
CSS 20.2%
HTML 0.7%
1# Author: Simon-Pierre Boucher2# Contact: contact@spboucher.ai3# Project: Toit-Ka4# -----------------------------------------------------------------------------5# typologie.py : vocabulaire unifié des types de biens.6# LOUER : unités locatives Lou-Ka (1½ … 6½+, Studio, Loft, Chambre, Condo,7# Maison, Appartement) — déjà propres à ~99 %, on replie les résidus8# (« Apartment », « MDV », « 6½ », valeurs parasites « 1 », « P »).9# ACHETER: types Immo-Ka (Maison, Condo, Terrain, Duplex…) — on décode les10# entités HTML cassées (« Vente d'entreprise ») et on regroupe11# les variantes rares.12# -----------------------------------------------------------------------------13from __future__ import annotations1415import html1617# --- location (Lou-Ka.unit_type) ----------------------------------------------1819_LOUER_MAP = {20 "1½": "1½", "2½": "2½", "3½": "3½", "4½": "4½", "5½": "5½",21 "6½": "6½+", "6½+": "6½+",22 "studio": "Studio", "studios / lofts / chambres": "Studio",23 "loft": "Loft", "chambre": "Chambre", "condo": "Condo",24 "maison": "Maison", "mdv": "Maison", "bungalow": "Maison",25 "triplex": "Maison", "penthouse": "Penthouse",26 "appartement": "Appartement", "apartment": "Appartement",27 "5 1/5": "4½",28}2930LOUER_TYPES_ORDONNES = ["1½", "2½", "3½", "4½", "5½", "6½+",31 "Studio", "Loft", "Chambre", "Condo",32 "Appartement", "Maison", "Penthouse"]333435def type_louer(unit_type: str | None) -> str:36 s = html.unescape(html.unescape((unit_type or "").strip()))37 if not s or s in {"1", "P", "p"}:38 return ""39 return _LOUER_MAP.get(s, _LOUER_MAP.get(s.lower(), s))404142# --- vente (Immo-Ka.property_type) --------------------------------------------4344_ACHETER_MAP = {45 "vente d'entreprise": "Commercial",46 "bâtisse et vente d'entreprise": "Commercial",47 "batisse et vente d'entreprise": "Commercial",48 "propriété à revenu": "Multiplex",49 "propriete a revenu": "Multiplex",50 "6 logements/unités et +": "Multiplex",51 "6 logements/unites et +": "Multiplex",52 "quadruplex": "Multiplex",53 "fermette/agricole": "Fermette/Agricole",54 "jumelé": "Maison", "jumele": "Maison",55 "maison de ville": "Maison",56 "bi-génération": "Maison", "bi-generation": "Maison",57 "domaine et villa": "Maison",58 "loft": "Condo",59}6061ACHETER_TYPES_ORDONNES = ["Maison", "Condo", "Duplex", "Triplex", "Multiplex",62 "Terrain", "Chalet", "Maison mobile",63 "Fermette/Agricole", "Commercial", "Autre"]646566def type_acheter(property_type: str | None) -> str:67 s = html.unescape(html.unescape((property_type or "").strip()))68 if not s:69 return ""70 return _ACHETER_MAP.get(s.lower(), s)71