Vrai-Prix — l'évaluation du vrai prix des propriétés résidentielles au Québec.
TypeScript 90.2%
JavaScript 3.5%
Python 3.4%
CSS 1.9%
HTML 0.6%
1// Vrai-Prix — groupes de types d'annonces Immo-Ka (module PUR : importable côté client).2export type TypeGroupKey =3 | "maison"4 | "condo"5 | "plex"6 | "terrain"7 | "chalet"8 | "fermette"9 | "mobile"10 | "commercial"11 | "autre";1213export const TYPE_GROUPS: { key: TypeGroupKey; fr: string; en: string }[] = [14 { key: "maison", fr: "Maison", en: "House" },15 { key: "condo", fr: "Condo", en: "Condo" },16 { key: "plex", fr: "Plex", en: "Plex" },17 { key: "terrain", fr: "Terrain", en: "Land" },18 { key: "chalet", fr: "Chalet", en: "Cottage" },19 { key: "fermette", fr: "Fermette / agricole", en: "Hobby farm" },20 { key: "mobile", fr: "Maison mobile", en: "Mobile home" },21 { key: "commercial", fr: "Commercial", en: "Commercial" },22 { key: "autre", fr: "Autre", en: "Other" },23];2425const fold = (s: string | null | undefined) =>26 (s ?? "")27 .normalize("NFD")28 .replace(/[\u0300-\u036f]/g, "")29 .toLowerCase()30 .trim();3132/** Type Immo-Ka (libre, sale) → groupe stable. Même logique que typeBucket du pipeline. */33export function typeGroup(pt: string | null): TypeGroupKey {34 const t = fold(pt);35 if (!t) return "autre";36 if (t.includes("condo")) return "condo";37 if (/(du|tri|quadru|multi)plex/.test(t) || t.includes("plex")) return "plex";38 if (t.includes("terrain") || t === "lot") return "terrain";39 if (t.includes("commerc") || t.includes("industri") || t.includes("bureau") || t.includes("service"))40 return "commercial";41 if (t.includes("chalet") || t.includes("recreativ")) return "chalet";42 if (t.includes("ferme") || t.includes("agric")) return "fermette";43 if (t.includes("mobile") || t.includes("roulotte")) return "mobile";44 if (45 t.includes("maison") ||46 t.includes("jumel") ||47 t.includes("detach") ||48 t.includes("residen") ||49 t === "propriete" ||50 t.includes("bungalow") ||51 t.includes("cottage")52 )53 return "maison";54 return "autre";55}5657/** groupe → type_prop du rôle (moteur) pour un sujet sans unité jumelée. */58export function groupToTypeProp(g: TypeGroupKey): string {59 switch (g) {60 case "condo":61 return "condo_ou_multi";62 case "plex":63 return "plex";64 case "terrain":65 return "terrain";66 case "chalet":67 return "chalet";68 case "mobile":69 return "maison_mobile";70 case "commercial":71 return "autre";72 default:73 return "unifamilial";74 }75}7677export function groupLabel(key: string, fr: boolean): string {78 const g = TYPE_GROUPS.find((x) => x.key === key);79 return g ? (fr ? g.fr : g.en) : key;80}81