From 3f8ead0a3e6bf5b5cf647feeb1019cc2d40bac3c Mon Sep 17 00:00:00 2001 From: sangwook yoo Date: Wed, 24 Jun 2026 14:43:04 +0900 Subject: [PATCH] =?UTF-8?q?feat(roof-shape):=20Gemini=20=EC=B6=9C=EB=A0=A5?= =?UTF-8?q?=20=EC=A0=95=EA=B7=9C=ED=99=94=20normalizeRoofShape=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [작업내용] : - raw 지붕형상 출력 → RoofShapeDescriptor(type/ridge/flows/confidence?) 정규화 - 어휘 밖 type/ridge 는 ''(매처 결측 관대), flows 는 어휘만 소문자화·중복제거 - 모두 비면 null, direction 비산출(매처 미사용) - route.js 배선은 다음 task Co-Authored-By: Claude Opus 4.8 --- src/common/roofShapePattern.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/common/roofShapePattern.js b/src/common/roofShapePattern.js index abba02a6..bf264c0f 100644 --- a/src/common/roofShapePattern.js +++ b/src/common/roofShapePattern.js @@ -126,3 +126,25 @@ export const matchRoofShapePattern = (descriptor) => { return candidate.shapeNum } + +// Gemini 자유 출력(raw) → 매처 strict 어휘로 정규화한 RoofShapeDescriptor | null. +// 어휘 밖 type/ridge 는 ''(매처가 결측 관대), flows 는 ROOF_FLOW 어휘만 소문자화·중복제거. +// type·ridge·flows 가 모두 비면 null. direction 은 산출하지 않는다(매처 미사용). +export const normalizeRoofShape = (raw) => { + if (!raw || typeof raw !== 'object') return null + + const norm = (value) => (typeof value === 'string' ? value.trim().toLowerCase() : '') + const TYPE_VALUES = Object.values(ROOF_SHAPE_TYPE) + const RIDGE_VALUES = Object.values(ROOF_RIDGE) + const FLOW_VALUES = Object.values(ROOF_FLOW) + + const type = TYPE_VALUES.includes(norm(raw.type)) ? norm(raw.type) : '' + const ridge = RIDGE_VALUES.includes(norm(raw.ridge)) ? norm(raw.ridge) : '' + const flows = Array.isArray(raw.flows) ? [...new Set(raw.flows.map(norm).filter((flow) => FLOW_VALUES.includes(flow)))] : [] + + if (!type && !ridge && flows.length === 0) return null + + const result = { type, ridge, flows } + if (typeof raw.confidence === 'number') result.confidence = raw.confidence + return result +}